vnetod/flake.nix

79 lines
2.1 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 = {
default = final: prev: {
vnetod = final.callPackage mkVnetod { };
};
2022-11-10 00:19:18 +03:00
colored = final: prev: {
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; };
vnetod = pkgs.callPackage mkVnetod { };
2022-11-10 00:19:18 +03:00
coloredVnetod = pkgs.callPackage mkVnetod { vnetodFeatures = [ "color" ]; };
2022-09-18 23:34:38 +03:00
docker = pkgs.dockerTools.buildLayeredImage {
name = "pleshevskiy/vnetod";
tag = cargoToml.package.version;
config = {
Volumes."/data" = { };
WorkingDir = "/data";
Entrypoint = [ "${vnetod}/bin/vnetod" ];
};
2022-09-18 23:34:38 +03:00
};
in
{
2022-11-10 00:19:18 +03:00
apps = {
default = {
type = "app";
program = "${vnetod}/bin/vnetod";
};
colored = {
type = "app";
program = "${coloredVnetod}/bin/vnetod";
};
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-10 00:19:18 +03:00
colored = coloredVnetod;
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
}