summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/trivial.nix9
-rw-r--r--nixos/modules/misc/version.nix6
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index a928e1dbca98..a6a4abba1189 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -58,11 +58,12 @@ rec {
inherit (lib.strings) fileContents;
+ version = fileContents ../.version;
+ suffix = let suffixFile = ../.version-suffix; in
+ if pathExists suffixFile then fileContents suffixFile else "pre-git";
+
# Return the Nixpkgs version number.
- nixpkgsVersion =
- let suffixFile = ../.version-suffix; in
- fileContents ../.version
- + (if pathExists suffixFile then fileContents suffixFile else "pre-git");
+ nixpkgsVersion = version + suffix;
# Whether we're being called by nix-shell.
inNixShell = builtins.getEnv "IN_NIX_SHELL" != "";
diff --git a/nixos/modules/misc/version.nix b/nixos/modules/misc/version.nix
index b8f0a223c910..d9d60b725093 100644
--- a/nixos/modules/misc/version.nix
+++ b/nixos/modules/misc/version.nix
@@ -5,8 +5,6 @@ with lib;
let
cfg = config.system.nixos;
- releaseFile = "${toString pkgs.path}/.version";
- suffixFile = "${toString pkgs.path}/.version-suffix";
revisionFile = "${toString pkgs.path}/.git-revision";
gitRepo = "${toString pkgs.path}/.git";
gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo);
@@ -25,14 +23,14 @@ in
nixos.release = mkOption {
readOnly = true;
type = types.str;
- default = fileContents releaseFile;
+ default = trivial.version;
description = "The NixOS release (e.g. <literal>16.03</literal>).";
};
nixos.versionSuffix = mkOption {
internal = true;
type = types.str;
- default = if pathExists suffixFile then fileContents suffixFile else "pre-git";
+ default = trivial.suffix;
description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
};