git.iko.soy/typeable/nixpkgs
on master help sign in
lib: deduplicate version/suffix references

The logic regarding the generated `.version-suffix` file is already defined in `lib/trivial.nix` and shouldn't be duplicated in `nixos/version`.

commit39909289f452fcd60127cbd2372f22ac35f25d08 authorMaximilian Bosch <maximilian@mbosch.me> dateTue 24 Apr 2018, 20:33 (9 years ago) parentf66cdc7
2 files changed+7−8
lib/trivial.nix+5−4 nixos/modules/misc/version.nix+2−4
lib/trivial.nix+5−4
@@ -58,11 +58,12 @@ rec {
5858
5959 inherit (lib.strings) fileContents;
6060
61+ version = fileContents ../.version;
62+ suffix = let suffixFile = ../.version-suffix; in
63+ if pathExists suffixFile then fileContents suffixFile else "pre-git";
64+
6165 # Return the Nixpkgs version number.
62− nixpkgsVersion =
63− let suffixFile = ../.version-suffix; in
64− fileContents ../.version
65− + (if pathExists suffixFile then fileContents suffixFile else "pre-git");
66+ nixpkgsVersion = version + suffix;
6667
6768 # Whether we're being called by nix-shell.
6869 inNixShell = builtins.getEnv "IN_NIX_SHELL" != "";
nixos/modules/misc/version.nix+2−4
@@ -5,8 +5,6 @@ with lib;
55let
66 cfg = config.system.nixos;
77
8− releaseFile = "${toString pkgs.path}/.version";
9− suffixFile = "${toString pkgs.path}/.version-suffix";
108 revisionFile = "${toString pkgs.path}/.git-revision";
119 gitRepo = "${toString pkgs.path}/.git";
1210 gitCommitId = lib.substring 0 7 (commitIdFromGitRepo gitRepo);
@@ -25,14 +23,14 @@ in
2523 nixos.release = mkOption {
2624 readOnly = true;
2725 type = types.str;
28− default = fileContents releaseFile;
26+ default = trivial.version;
2927 description = "The NixOS release (e.g. <literal>16.03</literal>).";
3028 };
3129
3230 nixos.versionSuffix = mkOption {
3331 internal = true;
3432 type = types.str;
35− default = if pathExists suffixFile then fileContents suffixFile else "pre-git";
33+ default = trivial.suffix;
3634 description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
3735 };
3836