at 18.09-beta 2.0 kB view raw
1{ config, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.system.nixos; 7in 8 9{ 10 11 options.system = { 12 13 nixos.label = mkOption { 14 type = types.str; 15 description = '' 16 NixOS version name to be used in the names of generated 17 outputs and boot labels. 18 19 If you ever wanted to influence the labels in your GRUB menu, 20 this is the option for you. 21 22 The default is <option>system.nixos.tags</option> separated by 23 "-" + "-" + <envar>NIXOS_LABEL_VERSION</envar> environment 24 variable (defaults to the value of 25 <option>system.nixos.version</option>). 26 27 Can be overriden by setting <envar>NIXOS_LABEL</envar>. 28 29 Useful for not loosing track of configurations built from different 30 nixos branches/revisions, e.g.: 31 32 <screen> 33 #!/bin/sh 34 today=`date +%Y%m%d` 35 branch=`(cd nixpkgs ; git branch 2>/dev/null | sed -n '/^\* / { s|^\* ||; p; }')` 36 revision=`(cd nixpkgs ; git rev-parse HEAD)` 37 export NIXOS_LABEL_VERSION="$today.$branch-''${revision:0:7}" 38 nixos-rebuild switch</screen> 39 ''; 40 }; 41 42 nixos.tags = mkOption { 43 type = types.listOf types.str; 44 default = []; 45 example = [ "with-xen" ]; 46 description = '' 47 Strings to prefix to the default 48 <option>system.nixos.label</option>. 49 50 Useful for not loosing track of configurations built with 51 different options, e.g.: 52 53 <screen> 54 { 55 system.nixos.tags = [ "with-xen" ]; 56 virtualisation.xen.enable = true; 57 } 58 </screen> 59 ''; 60 }; 61 62 }; 63 64 config = { 65 # This is set here rather than up there so that changing it would 66 # not rebuild the manual 67 system.nixos.label = mkDefault (maybeEnv "NIXOS_LABEL" 68 (concatStringsSep "-" ((sort (x: y: x < y) cfg.tags) 69 ++ [ (maybeEnv "NIXOS_LABEL_VERSION" cfg.version) ]))); 70 }; 71 72}