From dc66d1a643f492a22d15fa1bd5ec6bfa22f16358 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Sun, 25 Sep 2022 17:02:16 +0300 Subject: [PATCH] nix: move overlay to the top level --- flake.nix | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index 3e6529c..ce44c43 100644 --- a/flake.nix +++ b/flake.nix @@ -6,16 +6,13 @@ outputs = { self, nixpkgs, utils }: let - cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml)); + inherit (builtins) fromTOML readFile substring; - version = "${cargoToml.package.version}_${builtins.substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}"; - in - utils.lib.eachDefaultSystem (system: - let - inherit (nixpkgs) lib; - pkgs = import nixpkgs { inherit system; }; + cargoToml = fromTOML (readFile ./Cargo.toml); + version = "${cargoToml.package.version}_${substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}"; - vnetod = pkgs.rustPlatform.buildRustPackage { + mkVnetod = { lib, rustPlatform, ... }: + rustPlatform.buildRustPackage { name = "vnetod-${version}"; src = lib.cleanSource ./.; @@ -23,6 +20,17 @@ doCheck = true; }; + in + { + overlay = final: prev: { + vnetod = final.callPackage mkVnetod { }; + }; + } + // utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + + vnetod = pkgs.callPackage mkVnetod { }; docker = pkgs.dockerTools.buildLayeredImage { name = "pleshevskiy/vnetod"; @@ -41,7 +49,7 @@ }; packages = { - inherit docker; + inherit docker vnetod; default = vnetod; }; @@ -49,7 +57,5 @@ packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ]; RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; }; - - overlays = f: p: { inherit vnetod; }; }); }