diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix index 8f246a9278b70..7d644757627f5 100644 --- a/nixos/modules/misc/version.nix +++ b/nixos/modules/misc/version.nix @@ -52,7 +52,7 @@ in stateVersion = mkOption { type = types.str; - default = cfg.release; + default = throw "system.stateVersion needs to be set. Use the value of the current release."; description = '' Every once in a while, a new NixOS release may change configuration defaults in a way incompatible with stateful diff --git a/nixos/release.nix b/nixos/release.nix index 6b7564a9b9721..4ad34cf2a10cc 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -26,14 +26,16 @@ let }; }; allTests = - foldAttrs recursiveUpdate {} (map allTestsForSystem supportedSystems); + foldAttrs recursiveUpdate { } (map allTestsForSystem supportedSystems); pkgs = import ./.. { system = "x86_64-linux"; }; versionModule = - { system.nixos.versionSuffix = versionSuffix; + { + system.nixos.versionSuffix = versionSuffix; system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev; + system.stateVersion = mkForce "21.04"; }; makeModules = module: rest: [ configuration versionModule module rest ]; @@ -92,9 +94,10 @@ let buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix { inherit system; modules = makeModules module - ({ ... }: + ({ config, ... }: { fileSystems."/".device = mkDefault "/dev/sda1"; boot.loader.grub.device = mkDefault "/dev/sda"; + system.stateVersion = mkDefault config.system.version; }); }).config));