From 5643877cc1700ac3ea97a9940a423ce9e5dac920 Mon Sep 17 00:00:00 2001 From: Alexander Tomokhov Date: Wed, 27 Sep 2023 23:43:45 +0400 Subject: [PATCH] flake: embed NixOS configuration git commit sha1 into nixos.label --- flake.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flake.nix b/flake.nix index 6e83088..05c23d1 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,10 @@ }: let system = "x86_64-linux"; + cfgShortRev = + if self ? rev then builtins.substring 0 7 self.rev else "dirty"; + nixosLabel = config: + "${cfgShortRev}.${config.system.nixos.release}.${nixpkgs.shortRev}"; userdata = builtins.fromJSON (builtins.readFile userdata-json); hardware-configuration = import hardware-configuration-nix; in @@ -30,9 +34,14 @@ just-nixos = nixpkgs.lib.nixosSystem { specialArgs = { inherit system userdata; }; modules = [ + # SelfPrivacy overlay { nixpkgs.overlays = [ selfprivacy-overlay.overlay ]; } + # machine specifics hardware-configuration + # main configuration part ./configuration.nix + # we need to embed NixOS repository git commit sha1 + ({ config, ... }: { system.nixos.label = nixosLabel config; }) ]; }; };