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