2018-07-20 22:56:59 +02:00
|
|
|
{ config, lib, ... }:
|
2016-08-01 02:00:00 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2017-04-01 02:00:00 +02:00
|
|
|
cfg = config.system.nixos;
|
2016-08-01 02:00:00 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options.system = {
|
|
|
|
|
2017-04-01 02:00:00 +02:00
|
|
|
nixos.label = mkOption {
|
2016-08-01 02:00:00 +02:00
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
NixOS version name to be used in the names of generated
|
|
|
|
outputs and boot labels.
|
|
|
|
|
|
|
|
If you ever wanted to influence the labels in your GRUB menu,
|
|
|
|
this is the option for you.
|
2017-04-01 02:00:00 +02:00
|
|
|
|
|
|
|
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>
|
2016-08-01 02:00:00 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-04-01 02:00:00 +02:00
|
|
|
nixos.tags = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "with-xen" ];
|
|
|
|
description = ''
|
|
|
|
Strings to prefix to the default
|
|
|
|
<option>system.nixos.label</option>.
|
|
|
|
|
|
|
|
Useful for not loosing track of configurations built with
|
|
|
|
different options, e.g.:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
{
|
|
|
|
system.nixos.tags = [ "with-xen" ];
|
|
|
|
virtualisation.xen.enable = true;
|
|
|
|
}
|
|
|
|
</screen>
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-08-01 02:00:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
# This is set here rather than up there so that changing it would
|
|
|
|
# not rebuild the manual
|
2017-04-01 02:00:00 +02:00
|
|
|
system.nixos.label = mkDefault (maybeEnv "NIXOS_LABEL"
|
2018-02-22 20:44:21 +01:00
|
|
|
(concatStringsSep "-" ((sort (x: y: x < y) cfg.tags)
|
|
|
|
++ [ (maybeEnv "NIXOS_LABEL_VERSION" cfg.version) ])));
|
2016-08-01 02:00:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|