2018-07-20 21:56:59 +01:00
|
|
|
{ config, lib, ... }:
|
2016-08-01 01:00:00 +01:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2017-04-01 01:00:00 +01:00
|
|
|
cfg = config.system.nixos;
|
2016-08-01 01:00:00 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options.system = {
|
|
|
|
|
2017-04-01 01:00:00 +01:00
|
|
|
nixos.label = mkOption {
|
2022-07-15 10:45:25 +01:00
|
|
|
type = types.strMatching "[a-zA-Z0-9:_\\.-]*";
|
2022-08-30 13:08:50 +01:00
|
|
|
description = lib.mdDoc ''
|
2016-08-01 01:00:00 +01:00
|
|
|
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 01:00:00 +01:00
|
|
|
|
2022-07-15 10:45:25 +01:00
|
|
|
It can only contain letters, numbers and the following symbols:
|
2022-08-30 13:08:50 +01:00
|
|
|
`:`, `_`, `.` and `-`.
|
2022-07-15 10:45:25 +01:00
|
|
|
|
2022-08-30 13:08:50 +01:00
|
|
|
The default is {option}`system.nixos.tags` separated by
|
|
|
|
"-" + "-" + {env}`NIXOS_LABEL_VERSION` environment
|
2017-04-01 01:00:00 +01:00
|
|
|
variable (defaults to the value of
|
2022-08-30 13:08:50 +01:00
|
|
|
{option}`system.nixos.version`).
|
2017-04-01 01:00:00 +01:00
|
|
|
|
2022-08-30 13:08:50 +01:00
|
|
|
Can be overriden by setting {env}`NIXOS_LABEL`.
|
2017-04-01 01:00:00 +01:00
|
|
|
|
|
|
|
Useful for not loosing track of configurations built from different
|
|
|
|
nixos branches/revisions, e.g.:
|
|
|
|
|
2022-08-30 13:08:50 +01:00
|
|
|
```
|
2017-04-01 01:00:00 +01:00
|
|
|
#!/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}"
|
2022-08-30 11:35:47 +01:00
|
|
|
nixos-rebuild switch
|
2022-08-30 13:08:50 +01:00
|
|
|
```
|
2016-08-01 01:00:00 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-04-01 01:00:00 +01:00
|
|
|
nixos.tags = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "with-xen" ];
|
2022-08-30 13:08:50 +01:00
|
|
|
description = lib.mdDoc ''
|
2017-04-01 01:00:00 +01:00
|
|
|
Strings to prefix to the default
|
2022-08-30 13:08:50 +01:00
|
|
|
{option}`system.nixos.label`.
|
2017-04-01 01:00:00 +01:00
|
|
|
|
|
|
|
Useful for not loosing track of configurations built with
|
|
|
|
different options, e.g.:
|
|
|
|
|
2022-08-30 13:08:50 +01:00
|
|
|
```
|
2017-04-01 01:00:00 +01:00
|
|
|
{
|
|
|
|
system.nixos.tags = [ "with-xen" ];
|
|
|
|
virtualisation.xen.enable = true;
|
|
|
|
}
|
2022-08-30 13:08:50 +01:00
|
|
|
```
|
2017-04-01 01:00:00 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-08-01 01:00:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
# This is set here rather than up there so that changing it would
|
|
|
|
# not rebuild the manual
|
2017-04-01 01:00:00 +01:00
|
|
|
system.nixos.label = mkDefault (maybeEnv "NIXOS_LABEL"
|
2018-02-22 19:44:21 +00:00
|
|
|
(concatStringsSep "-" ((sort (x: y: x < y) cfg.tags)
|
|
|
|
++ [ (maybeEnv "NIXOS_LABEL_VERSION" cfg.version) ])));
|
2016-08-01 01:00:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|