Skip to content

Commit

Permalink
Write just ./.version on all components
Browse files Browse the repository at this point in the history
This way it's easier to get right. See previous commit.
  • Loading branch information
roberth committed Feb 18, 2025
1 parent bba4e6b commit 3556f6b
Show file tree
Hide file tree
Showing 23 changed files with 16 additions and 178 deletions.
15 changes: 15 additions & 0 deletions packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ let
mkPackageBuilder =
exts: userFn: stdenv.mkDerivation (lib.extends (lib.composeManyExtensions exts) userFn);

setVersionLayer = finalAttrs: prevAttrs: {
preConfigure =
prevAttrs.prevAttrs or ""
+
# Update the repo-global .version file.
# Symlink ./.version points there, but by default only workDir is writable.
''
chmod u+w ./.version
echo ${finalAttrs.version} > ./.version
'';
};

localSourceLayer =
finalAttrs: prevAttrs:
let
Expand Down Expand Up @@ -180,12 +192,14 @@ scope:
mkMesonDerivation = mkPackageBuilder [
miscGoodPractice
localSourceLayer
setVersionLayer
mesonLayer
];
mkMesonExecutable = mkPackageBuilder [
miscGoodPractice
bsdNoLinkAsNeeded
localSourceLayer
setVersionLayer
mesonLayer
mesonBuildLayer
];
Expand All @@ -194,6 +208,7 @@ scope:
bsdNoLinkAsNeeded
localSourceLayer
mesonLayer
setVersionLayer
mesonBuildLayer
mesonLibraryLayer
];
Expand Down
8 changes: 0 additions & 8 deletions src/libcmd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
(lib.mesonEnable "markdown" enableMarkdown)
(lib.mesonOption "readline-flavor" readlineFlavor)
Expand Down
8 changes: 0 additions & 8 deletions src/libexpr-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ mkMesonLibrary (finalAttrs: {
nix-expr
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libexpr-test-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
rapidcheck
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libexpr-tests/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ mkMesonExecutable (finalAttrs: {
gtest
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libexpr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json
] ++ lib.optional enableGC boehmgc;

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
(lib.mesonEnable "gc" enableGC)
];
Expand Down
8 changes: 0 additions & 8 deletions src/libfetchers-tests/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ mkMesonExecutable (finalAttrs: {
gtest
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libfetchers/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
Expand Down
8 changes: 0 additions & 8 deletions src/libflake-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ mkMesonLibrary (finalAttrs: {
nix-flake
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libflake-tests/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ mkMesonExecutable (finalAttrs: {
gtest
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libflake/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
Expand Down
8 changes: 0 additions & 8 deletions src/libmain-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
nix-main
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libmain/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ mkMesonLibrary (finalAttrs: {
openssl
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
Expand Down
8 changes: 0 additions & 8 deletions src/libstore-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ mkMesonLibrary (finalAttrs: {
nix-store
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libstore-test-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ mkMesonLibrary (finalAttrs: {
rapidcheck
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libstore-tests/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ mkMesonExecutable (finalAttrs: {
nix-store-test-support
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libstore/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags =
[
(lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux)
Expand Down
8 changes: 0 additions & 8 deletions src/libutil-c/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ mkMesonLibrary (finalAttrs: {
nix-util
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libutil-test-support/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ mkMesonLibrary (finalAttrs: {
rapidcheck
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
8 changes: 0 additions & 8 deletions src/libutil-tests/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ mkMesonExecutable (finalAttrs: {
gtest
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
];

Expand Down
11 changes: 0 additions & 11 deletions src/libutil/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ mkMesonLibrary (finalAttrs: {
nlohmann_json
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
#
# TODO: change release process to add `pre` in `.version`, remove it
# before tagging, and restore after.
''
chmod u+w ./.version
echo ${version} > ../../.version
'';

mesonFlags = [
(lib.mesonEnable "cpuid" stdenv.hostPlatform.isx86_64)
];
Expand Down
8 changes: 0 additions & 8 deletions src/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ mkMesonExecutable (finalAttrs: {
nix-cmd
];

preConfigure =
# Update the repo-global .version file.
# Symlink ./.version points there, but by default only workDir is writable.
''
chmod u+w ./.version
echo ${version} > ./.version
'';

mesonFlags = [
];

Expand Down
8 changes: 1 addition & 7 deletions tests/functional/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,10 @@ mkMesonDerivation (
];

preConfigure =
# "Inline" .version so it's not a symlink, and includes the suffix.
# Do the meson utils, without modification.
''
chmod u+w ./.version
echo ${version} > ../../../.version
''
# TEMP hack for Meson before make is gone, where
# `src/nix-functional-tests` is during the transition a symlink and
# not the actual directory directory.
+ ''
''
cd $(readlink -e $PWD)
echo $PWD | grep tests/functional
'';
Expand Down

0 comments on commit 3556f6b

Please sign in to comment.