77 lines
2 KiB
Nix
77 lines
2 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
let
|
|
inherit (builtins) fromTOML readFile substring;
|
|
|
|
cargoToml = fromTOML (readFile ./Cargo.toml);
|
|
version = "${cargoToml.package.version}+${substring 0 8 self.lastModifiedDate}.${self.shortRev or "dirty"}";
|
|
|
|
mkVnetod = { lib, rustPlatform, vnetodFeatures ? [ ], ... }:
|
|
rustPlatform.buildRustPackage {
|
|
name = "vnetod-${version}";
|
|
|
|
src = lib.cleanSource ./.;
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
|
|
buildFeatures = vnetodFeatures;
|
|
|
|
doCheck = true;
|
|
};
|
|
in
|
|
{
|
|
overlays = {
|
|
minimal = final: prev: {
|
|
vnetod = final.callPackage mkVnetod { };
|
|
};
|
|
default = final: prev: {
|
|
vnetod = final.callPackage mkVnetod {
|
|
vnetodFeatures = [ "color" ];
|
|
};
|
|
};
|
|
};
|
|
}
|
|
// flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
vnetod = pkgs.callPackage mkVnetod { vnetodFeatures = [ "color" ]; };
|
|
minimalVnetod = pkgs.callPackage mkVnetod { };
|
|
|
|
docker = pkgs.dockerTools.buildLayeredImage {
|
|
name = "pleshevskiy/vnetod";
|
|
tag = cargoToml.package.version;
|
|
config = {
|
|
Volumes."/data" = { };
|
|
WorkingDir = "/data";
|
|
Entrypoint = [ "${vnetod}/bin/vnetod" ];
|
|
};
|
|
};
|
|
|
|
mkApp = prog: {
|
|
type = "app";
|
|
program = "${vnetod}/bin/vnetod";
|
|
};
|
|
in
|
|
{
|
|
apps = {
|
|
default = mkApp vnetod;
|
|
minimal = mkApp minimalVnetod;
|
|
};
|
|
|
|
packages = {
|
|
inherit docker vnetod;
|
|
default = vnetod;
|
|
minimal = minimalVnetod;
|
|
};
|
|
|
|
devShell = pkgs.mkShell {
|
|
packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ];
|
|
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
|
|
};
|
|
});
|
|
}
|