git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #39416 from Ma27/fix-.version-config

.version: don't read from `.version` and deduplicate `.version-suffix` references

commitfd8dcdfa9d3262429ff0ec2ea2d05cd894295740 authorMichael Raskin <7c6f434c@mail.ru> dateMon 30 Apr 2018, 08:33 (9 years ago) parent9b706309274ea3
10 files changed+20−18
.editorconfig−4 .version+1−1 doc/Makefile+1−1 doc/default.nix+1−1 lib/default.nix+1−1 lib/trivial.nix+7−4 nixos/doc/manual/release-notes/rl-1809.xml+5 nixos/maintainers/scripts/ec2/create-amis.sh+1−1 nixos/modules/misc/version.nix+2−4 pkgs/tools/system/osquery/default.nix+1−1
.editorconfig−4
@@ -26,7 +26,3 @@ indent_size = 4
2626# Match diffs, avoid to trim trailing whitespace
2727[*.{diff,patch}]
2828trim_trailing_whitespace = false
29−
30−# https://github.com/NixOS/nixpkgs/pull/39336#discussion_r183387754
31−[.version]
32−insert_final_newline = false
.version+1−1
@@ -1 +1 @@
1−18.09
1+18.09
doc/Makefile+1−1
@@ -64,7 +64,7 @@ manual-full.xml: ${MD_TARGETS} .version *.xml
6464
6565.version:
6666 nix-instantiate --eval \
67− -E '(import ../lib).nixpkgsVersion' > .version
67+ -E '(import ../lib).version' > .version
6868
6969%.section.xml: %.section.md
7070 pandoc $^ -w docbook+smart \
doc/default.nix+1−1
@@ -30,7 +30,7 @@ pkgs.stdenv.mkDerivation {
3030 ];
3131
3232 postPatch = ''
33− echo ${lib.nixpkgsVersion} > .version
33+ echo ${lib.version} > .version
3434 '';
3535
3636 installPhase = ''
lib/default.nix+1−1
@@ -58,7 +58,7 @@ let
5858 replaceStrings seq stringLength sub substring tail;
5959 inherit (trivial) id const concat or and boolToString mergeAttrs
6060 flip mapNullable inNixShell min max importJSON warn info
61− nixpkgsVersion mod compare splitByAndCompare
61+ nixpkgsVersion version mod compare splitByAndCompare
6262 functionArgs setFunctionArgs isFunction;
6363
6464 inherit (fixedPoints) fix fix' extends composeExtensions
lib/trivial.nix+7−4
@@ -58,11 +58,14 @@ rec {
5858
5959 inherit (lib.strings) fileContents;
6060
61+ release = fileContents ../.version;
62+ versionSuffix = 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+ version = release + versionSuffix;
67+
68+ nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" version;
6669
6770 # Whether we're being called by nix-shell.
6871 inNixShell = builtins.getEnv "IN_NIX_SHELL" != "";
nixos/doc/manual/release-notes/rl-1809.xml+5
@@ -132,6 +132,11 @@ following incompatible changes:</para>
132132 <literal>lib.traceCallXml</literal> has been deprecated. Please complain
133133 if you use the function regularly.
134134 </para>
135+ <para>
136+ The attribute <literal>lib.nixpkgsVersion</literal> has been deprecated in favor of
137+ <literal>lib.version</literal>. Please refer to the discussion in
138+ <link xlink:href="https://github.com/NixOS/nixpkgs/pull/39416#discussion_r183845745">NixOS/nixpkgs#39416</link> for further reference.
139+ </para>
135140 </listitem>
136141</itemizedlist>
137142
nixos/maintainers/scripts/ec2/create-amis.sh+1−1
@@ -6,7 +6,7 @@
66set -e
77set -o pipefail
88
9−version=$(nix-instantiate --eval --strict '<nixpkgs>' -A lib.nixpkgsVersion | sed s/'"'//g)
9+version=$(nix-instantiate --eval --strict '<nixpkgs>' -A lib.version | sed s/'"'//g)
1010major=${version:0:5}
1111echo "NixOS version is $version ($major)"
1212
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.release;
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.versionSuffix;
3634 description = "The NixOS version suffix (e.g. <literal>1160.f2d4ee1</literal>).";
3735 };
3836
pkgs/tools/system/osquery/default.nix+1−1
@@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
2424
2525 # this is what `osquery --help` will show as the version.
2626 OSQUERY_BUILD_VERSION = version;
27− OSQUERY_PLATFORM = "nixos;${builtins.readFile "${toString path}/.version"}";
27+ OSQUERY_PLATFORM = "nixos;${stdenv.lib.version}";
2828
2929 src = fetchFromGitHub {
3030 owner = "facebook";