diff options
author | Jan Malakhovski <oxij@oxij.org> | 2015-09-18 16:50:48 +0000 |
---|---|---|
committer | Jan Malakhovski <oxij@oxij.org> | 2016-01-08 22:26:15 +0000 |
commit | 119c8f91e7f17d2cb95f42985816820600c389cf (patch) | |
tree | 0bd34b6a522114777f34668fb6d6c36c331eaea1 /nixos/modules/misc/version.nix | |
parent | 732eb3c4ccaac3312fe9334b5d77b3b88140c971 (diff) | |
download | nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.gz nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.bz2 nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.lz nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.xz nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.tar.zst nixlib-119c8f91e7f17d2cb95f42985816820600c389cf.zip |
nixos: introduce system.nixosLabel option and use it where appropriate
Setting nixosVersion to something custom is useful for meaningful GRUB menus and /nix/store paths, but actuallly changing it rebulids the whole system path (because of `nixos-version` script and manual pages). Also, changing it is not a particularly good idea because you can then be differentitated from other NixOS users by a lot of programs that read /etc/os-release. This patch introduces an alternative option that does all you want from nixosVersion, but rebuilds only the very top system level and /etc while using your label in the names of system /nix/store paths, GRUB and other boot loaders' menus, getty greetings and so on.
Diffstat (limited to 'nixos/modules/misc/version.nix')
-rw-r--r-- | nixos/modules/misc/version.nix | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index ee6948db3d3a..18f270cd531b 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -30,6 +30,29 @@ in ''; }; + nixosLabel = mkOption { + 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 option is for you. + + Can be set directly or with <envar>NIXOS_LABEL</envar> + environment variable for <command>nixos-rebuild</command>, + 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="$today.$branch-''${revision:0:7}" + nixos-rebuild switch</screen> + ''; + }; + nixosVersion = mkOption { internal = true; type = types.str; @@ -75,8 +98,9 @@ in config = { system = { - # This is set here rather than up there so that changing this - # env variable will not rebuild the manual + # These defaults are set here rather than up there so that + # changing them would not rebuild the manual + nixosLabel = mkDefault (maybeEnv "NIXOS_LABEL" cfg.nixosVersion); nixosVersion = mkDefault (maybeEnv "NIXOS_VERSION" (cfg.nixosRelease + cfg.nixosVersionSuffix)); # Note: code names must only increase in alphabetical order. |