From c6d8a58e8d3a9751197e8f731e823c08f5ee5dc3 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Sat, 1 Apr 2017 00:00:00 +0000 Subject: nixos: allow overriding labels with environment variables This reintroduces a better version of what 2a05368ff3217175cd87105e778e2e70bc7eef1c removed. --- nixos/modules/misc/label.nix | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'nixos/modules') diff --git a/nixos/modules/misc/label.nix b/nixos/modules/misc/label.nix index b4e88915d829..250914e8f82e 100644 --- a/nixos/modules/misc/label.nix +++ b/nixos/modules/misc/label.nix @@ -18,6 +18,24 @@ in If you ever wanted to influence the labels in your GRUB menu, this is the option for you. + + The default is separated by + "-" + "-" + NIXOS_LABEL_VERSION environment + variable (defaults to the value of + ). + + Can be overriden by setting NIXOS_LABEL. + + Useful for not loosing track of configurations built from different + nixos branches/revisions, e.g.: + + + #!/bin/sh + today=`date +%Y%m%d` + branch=`(cd nixpkgs ; git branch 2>/dev/null | sed -n '/^\* / { s|^\* ||; p; }')` + revision=`(cd nixpkgs ; git rev-parse HEAD)` + export NIXOS_LABEL_VERSION="$today.$branch-''${revision:0:7}" + nixos-rebuild switch ''; }; @@ -46,7 +64,9 @@ in config = { # This is set here rather than up there so that changing it would # not rebuild the manual - system.nixos.label = mkDefault (concatStringsSep "-" (sort (x: y: x < y) cfg.tags) + "-" + cfg.version); + system.nixos.label = mkDefault (maybeEnv "NIXOS_LABEL" + (concatStringsSep "-" (sort (x: y: x < y) cfg.tags) + + "-" + maybeEnv "NIXOS_LABEL_VERSION" cfg.version)); }; } -- cgit 1.4.1