nixos: allow overriding labels with environment variables
This reintroduces a better version of what 2a05368ff3
removed.
This commit is contained in:
parent
0fd8ce96ac
commit
c6d8a58e8d
1 changed files with 21 additions and 1 deletions
|
@ -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 <option>system.nixos.tags</option> separated by
|
||||
"-" + "-" + <envar>NIXOS_LABEL_VERSION</envar> environment
|
||||
variable (defaults to the value of
|
||||
<option>system.nixos.version</option>).
|
||||
|
||||
Can be overriden by setting <envar>NIXOS_LABEL</envar>.
|
||||
|
||||
Useful for not loosing track of configurations built from different
|
||||
nixos branches/revisions, e.g.:
|
||||
|
||||
<screen>
|
||||
#!/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</screen>
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -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));
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue