From 17117cf5658c107df9f7ffdda1999c668ea67ecc Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 14 Feb 2024 16:42:03 +0100 Subject: [PATCH 1/4] lib flake: Fix version Manually tested with nix-repl> :lf path:lib nix-repl> lib.version --- lib/.version | 1 + lib/tests/test-with-nix.nix | 9 +++++++++ lib/trivial.nix | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 lib/.version diff --git a/lib/.version b/lib/.version new file mode 100644 index 000000000000..420f61e8c7f6 --- /dev/null +++ b/lib/.version @@ -0,0 +1 @@ +24.05 \ No newline at end of file diff --git a/lib/tests/test-with-nix.nix b/lib/tests/test-with-nix.nix index fd2e7532e697..9bc160a4682a 100644 --- a/lib/tests/test-with-nix.nix +++ b/lib/tests/test-with-nix.nix @@ -49,6 +49,15 @@ pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}" { nix-store --init + # nixpkgs/lib/.version is a copy of nixpkgs/.version, so that the lib + # subtree is valid in isolation (except for the tests, but that's ok) + cp ${../../.version} nixpkgs-.version + cp ${../.version} nixpkgs-lib-.version + diff -U3 nixpkgs-.version nixpkgs-lib-.version || { + echo ' and must match.' + exit 1 + } + cp -r ${../.} lib echo "Running lib/tests/modules.sh" bash lib/tests/modules.sh diff --git a/lib/trivial.nix b/lib/trivial.nix index 58620006de15..d88f41f4123a 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -174,7 +174,7 @@ in { version = release + versionSuffix; /* Returns the current nixpkgs release number as string. */ - release = lib.strings.fileContents ../.version; + release = lib.strings.fileContents ./.version; /* The latest release that is supported, at the time of release branch-off, if applicable. From f45844cb558bc261a3a4d91054fba81f5d6fedee Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 14 Feb 2024 16:43:08 +0100 Subject: [PATCH 2/4] .version: Make lib/.version source of truth This way we don't have to make sure they're in sync, and we remove a small step from the release process. --- .version | 2 +- lib/tests/test-with-nix.nix | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) mode change 100644 => 120000 .version diff --git a/.version b/.version deleted file mode 100644 index 420f61e8c7f6..000000000000 --- a/.version +++ /dev/null @@ -1 +0,0 @@ -24.05 \ No newline at end of file diff --git a/.version b/.version new file mode 120000 index 000000000000..a408b4d1748c --- /dev/null +++ b/.version @@ -0,0 +1 @@ +lib/.version \ No newline at end of file diff --git a/lib/tests/test-with-nix.nix b/lib/tests/test-with-nix.nix index 9bc160a4682a..fd2e7532e697 100644 --- a/lib/tests/test-with-nix.nix +++ b/lib/tests/test-with-nix.nix @@ -49,15 +49,6 @@ pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}" { nix-store --init - # nixpkgs/lib/.version is a copy of nixpkgs/.version, so that the lib - # subtree is valid in isolation (except for the tests, but that's ok) - cp ${../../.version} nixpkgs-.version - cp ${../.version} nixpkgs-lib-.version - diff -U3 nixpkgs-.version nixpkgs-lib-.version || { - echo ' and must match.' - exit 1 - } - cp -r ${../.} lib echo "Running lib/tests/modules.sh" bash lib/tests/modules.sh From bb036f248694dbeaf7f69122f701f9d9ff394c4d Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 14 Feb 2024 16:57:43 +0100 Subject: [PATCH 3/4] lib/tests/release: Test lib.version in isolation --- lib/tests/test-with-nix.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tests/test-with-nix.nix b/lib/tests/test-with-nix.nix index fd2e7532e697..9d66b91cab42 100644 --- a/lib/tests/test-with-nix.nix +++ b/lib/tests/test-with-nix.nix @@ -53,6 +53,12 @@ pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}" { echo "Running lib/tests/modules.sh" bash lib/tests/modules.sh + echo "Checking lib.version" + nix-instantiate lib -A version --eval || { + echo "lib.version does not evaluate when lib is isolated from the rest of the nixpkgs tree" + exit 1 + } + echo "Running lib/tests/filesystem.sh" TEST_LIB=$PWD/lib bash lib/tests/filesystem.sh From 324a7aa90ee02f5401adcf5f4f859f50972feaf1 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 14 Feb 2024 17:09:44 +0100 Subject: [PATCH 4/4] .editorconfig: Add rule for .editorconfig This is not new and should have been written when .editorconfig was introduced. --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index c4682829e357..429370be9752 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,6 +17,10 @@ end_of_line = unset insert_final_newline = unset trim_trailing_whitespace = unset +# We want readFile .version to return the version without a newline. +[.version] +insert_final_newline = false + # see https://nixos.org/nixpkgs/manual/#chap-conventions # Match json/lockfiles/markdown/nix/perl/python/ruby/shell/docbook files, set indent to spaces