vnetod/flake.nix

78 lines
2 KiB
Nix
Raw Normal View History

2022-07-31 23:24:46 +03:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
2022-07-31 23:24:46 +03:00
};
outputs = { self, nixpkgs, flake-utils }:
let
2022-09-25 17:02:16 +03:00
inherit (builtins) fromTOML readFile substring;
2022-09-25 17:02:16 +03:00
cargoToml = fromTOML (readFile ./Cargo.toml);
2022-11-07 23:36:54 +03:00
version = "${cargoToml.package.version}+${substring 0 8 self.lastModifiedDate}.${self.shortRev or "dirty"}";
2022-09-18 23:34:38 +03:00
2022-11-10 00:19:18 +03:00
mkVnetod = { lib, rustPlatform, vnetodFeatures ? [ ], ... }:
2022-09-25 17:02:16 +03:00
rustPlatform.buildRustPackage {
2022-09-18 23:34:38 +03:00
name = "vnetod-${version}";
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
2022-11-10 00:19:18 +03:00
buildFeatures = vnetodFeatures;
2022-09-18 23:34:38 +03:00
doCheck = true;
};
2022-09-25 17:02:16 +03:00
in
{
2022-11-10 00:19:18 +03:00
overlays = {
2022-11-14 14:12:45 +03:00
minimal = final: prev: {
vnetod = final.callPackage mkVnetod { };
};
2022-11-14 14:12:45 +03:00
default = final: prev: {
2022-11-10 00:19:18 +03:00
vnetod = final.callPackage mkVnetod {
vnetodFeatures = [ "color" ];
};
};
2022-09-25 17:02:16 +03:00
};
}
// flake-utils.lib.eachDefaultSystem (system:
2022-09-25 17:02:16 +03:00
let
pkgs = import nixpkgs { inherit system; };
2022-11-12 17:07:01 +03:00
vnetod = pkgs.callPackage mkVnetod { vnetodFeatures = [ "color" ]; };
minimalVnetod = pkgs.callPackage mkVnetod { };
2022-09-18 23:34:38 +03:00
docker = pkgs.dockerTools.buildLayeredImage {
name = "pleshevskiy/vnetod";
tag = cargoToml.package.version;
config = {
Volumes."/data" = { };
WorkingDir = "/data";
2022-11-12 17:07:01 +03:00
Entrypoint = [ "${vnetod}/bin/vnetod" ];
};
2022-09-18 23:34:38 +03:00
};
2022-11-12 16:37:16 +03:00
mkApp = prog: {
type = "app";
program = "${vnetod}/bin/vnetod";
};
2022-09-18 23:34:38 +03:00
in
{
2022-11-10 00:19:18 +03:00
apps = {
2022-11-12 16:37:16 +03:00
default = mkApp vnetod;
2022-11-12 17:07:01 +03:00
minimal = mkApp minimalVnetod;
2022-09-18 23:34:38 +03:00
};
packages = {
2022-09-25 17:02:16 +03:00
inherit docker vnetod;
2022-09-18 23:34:38 +03:00
default = vnetod;
2022-11-12 17:07:01 +03:00
minimal = minimalVnetod;
2022-09-18 23:34:38 +03:00
};
devShell = pkgs.mkShell {
packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
};
});
2022-07-31 23:24:46 +03:00
}