at 22.05-pre 4.0 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.system.nixos; 7in 8 9{ 10 imports = [ 11 (mkRenamedOptionModule [ "system" "nixosVersion" ] [ "system" "nixos" "version" ]) 12 (mkRenamedOptionModule [ "system" "nixosVersionSuffix" ] [ "system" "nixos" "versionSuffix" ]) 13 (mkRenamedOptionModule [ "system" "nixosRevision" ] [ "system" "nixos" "revision" ]) 14 (mkRenamedOptionModule [ "system" "nixosLabel" ] [ "system" "nixos" "label" ]) 15 ]; 16 17 options.system = { 18 19 nixos.version = mkOption { 20 internal = true; 21 type = types.str; 22 description = "The full NixOS version (e.g. <literal>16.03.1160.f2d4ee1</literal>)."; 23 }; 24 25 nixos.release = mkOption { 26 readOnly = true; 27 type = types.str; 28 default = trivial.release; 29 description = "The NixOS release (e.g. <literal>16.03</literal>)."; 30 }; 31 32 nixos.versionSuffix = mkOption { 33 internal = true; 34 type = types.str; 35 default = trivial.versionSuffix; 36 description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>)."; 37 }; 38 39 nixos.revision = mkOption { 40 internal = true; 41 type = types.nullOr types.str; 42 default = trivial.revisionWithDefault null; 43 description = "The Git revision from which this NixOS configuration was built."; 44 }; 45 46 nixos.codeName = mkOption { 47 readOnly = true; 48 type = types.str; 49 default = trivial.codeName; 50 description = "The NixOS release code name (e.g. <literal>Emu</literal>)."; 51 }; 52 53 stateVersion = mkOption { 54 type = types.str; 55 default = cfg.release; 56 description = '' 57 Every once in a while, a new NixOS release may change 58 configuration defaults in a way incompatible with stateful 59 data. For instance, if the default version of PostgreSQL 60 changes, the new version will probably be unable to read your 61 existing databases. To prevent such breakage, you should set the 62 value of this option to the NixOS release with which you want 63 to be compatible. The effect is that NixOS will use 64 defaults corresponding to the specified release (such as using 65 an older version of PostgreSQL). 66 Its perfectly fine and recommended to leave this value at the 67 release version of the first install of this system. 68 Changing this option will not upgrade your system. In fact it 69 is meant to stay constant exactly when you upgrade your system. 70 You should only bump this option, if you are sure that you can 71 or have migrated all state on your system which is affected 72 by this option. 73 ''; 74 }; 75 76 defaultChannel = mkOption { 77 internal = true; 78 type = types.str; 79 default = "https://nixos.org/channels/nixos-unstable"; 80 description = "Default NixOS channel to which the root user is subscribed."; 81 }; 82 83 configurationRevision = mkOption { 84 type = types.nullOr types.str; 85 default = null; 86 description = "The Git revision of the top-level flake from which this configuration was built."; 87 }; 88 89 }; 90 91 config = { 92 93 system.nixos = { 94 # These defaults are set here rather than up there so that 95 # changing them would not rebuild the manual 96 version = mkDefault (cfg.release + cfg.versionSuffix); 97 }; 98 99 # Generate /etc/os-release. See 100 # https://www.freedesktop.org/software/systemd/man/os-release.html for the 101 # format. 102 environment.etc.os-release.text = 103 '' 104 NAME=NixOS 105 ID=nixos 106 VERSION="${cfg.release} (${cfg.codeName})" 107 VERSION_CODENAME=${toLower cfg.codeName} 108 VERSION_ID="${cfg.release}" 109 BUILD_ID="${cfg.version}" 110 PRETTY_NAME="NixOS ${cfg.release} (${cfg.codeName})" 111 LOGO="nix-snowflake" 112 HOME_URL="https://nixos.org/" 113 DOCUMENTATION_URL="https://nixos.org/learn.html" 114 SUPPORT_URL="https://nixos.org/community.html" 115 BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues" 116 ''; 117 118 }; 119 120}