summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-10-01 17:00:22 +0200
committerDaiderd Jordan <daiderd@gmail.com>2017-10-01 17:00:44 +0200
commit36ba568fc46df8fe2f142892bb1f9bc678a0ebe4 (patch)
treea749b5749edaa80900735ef9b4bcd5b6dc097427 /modules/system
parent312bc0ee9a8179d67e03939a325c054bc55806b1 (diff)
system-version: add assertioon for stateVersion
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/version.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/system/version.nix b/modules/system/version.nix
index 5a6b247..087e8dd 100644
--- a/modules/system/version.nix
+++ b/modules/system/version.nix
@@ -1,10 +1,12 @@
-{ config, lib, pkgs, ... }:
+{ options, config, lib, pkgs, ... }:
with lib;
let
cfg = config.system;
+ defaultStateVersion = options.system.stateVersion.default;
+
gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo);
gitRepo = "${toString pkgs.path}/.git";
releaseFile = "${toString pkgs.path}/.version";
@@ -72,5 +74,7 @@ in
system.nixpkgsRevision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
system.nixpkgsVersionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
+ assertions = [ { assertion = cfg.stateVersion <= defaultStateVersion; message = "system.stateVersion = ${toString cfg.stateVersion}; is not a valid value"; } ];
+
};
}