Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packaging/hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,14 @@ rec {
system:
let
pkgs = nixpkgsFor.${system}.native;
nix-1_11 = pkgs.callPackage ./testing/nix-1.11.nix { };
in
pkgs.runCommand "install-tests" {
againstSelf = testNixVersions pkgs pkgs.nix;
againstCurrentLatest =
# FIXME: temporarily disable this on macOS because of #3605.
if system == "x86_64-linux" then testNixVersions pkgs pkgs.nixVersions.latest else null;
against-1_11 = if system == "x86_64-linux" then testNixVersions pkgs nix-1_11 else null;
# Disabled because the latest stable version doesn't handle
# `NIX_DAEMON_SOCKET_PATH` which is required for the tests to work
# againstLatestStable = testNixVersions pkgs pkgs.nixStable;
Expand Down
14 changes: 14 additions & 0 deletions packaging/testing/nix-1.11-socket-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -77,7 +77,9 @@ void Settings::processEnvironment()
nixConfDir = canonPath(getEnv("NIX_CONF_DIR", NIX_CONF_DIR));
nixLibexecDir = canonPath(getEnv("NIX_LIBEXEC_DIR", NIX_LIBEXEC_DIR));
nixBinDir = canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR));
- nixDaemonSocketFile = canonPath(nixStateDir + DEFAULT_SOCKET_PATH);
+ nixDaemonSocketFile = canonPath(
+ getEnv("NIX_DAEMON_SOCKET_PATH",
+ nixStateDir + DEFAULT_SOCKET_PATH));

// should be set with the other config options, but depends on nixLibexecDir
#ifdef __APPLE__
104 changes: 104 additions & 0 deletions packaging/testing/nix-1.11.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Build Nix 1.11.x from the 1.11-maintenance branch for compatibility testing.
# Not directly exposed, for testing only.
# See .#checks.x86_64-linux.installTests.against-1_11
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
autoconf-archive,
bison,
flex,
curl,
perl,
perlPackages,
bzip2,
xz,
openssl,
pkg-config,
sqlite,
boehmgc,
libseccomp,
libsodium,
}:

stdenv.mkDerivation {
pname = "nix";
version = "1.11.16";

src = fetchFromGitHub {
owner = "NixOS";
repo = "nix";
rev = "c6e15c43222cbec54969322b863c9eb426f58499"; # 1.11.16
hash = "sha256-hGZ/Dvm2s6QIQsyDLlxDetC7qGExxDwMkWYk5E2+oj8=";
};

nativeBuildInputs = [
autoreconfHook
autoconf-archive
bison
flex
pkg-config
];

buildInputs = [
curl
perl
bzip2
xz
openssl
sqlite
boehmgc
]
++ lib.optional stdenv.hostPlatform.isLinux libseccomp
++ lib.optional (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) libsodium;

configureFlags = [
"--disable-init-state"
"--with-dbi=${perlPackages.DBI}/${perl.libPrefix}"
"--with-dbd-sqlite=${perlPackages.DBDSQLite}/${perl.libPrefix}"
"--with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix}"
"--enable-gc"
"--sysconfdir=${placeholder "out"}/etc"
];

makeFlags = [
"profiledir=$(out)/etc/profile.d"
];

installFlags = [
"sysconfdir=$(out)/etc"
];

enableParallelBuilding = true;

patches = [
# Support NIX_DAEMON_SOCKET_PATH for compatibility tests
./nix-1.11-socket-path.patch
];

postPatch = ''
# -Wno-unneeded-internal-declaration and -Wno-deprecated-register are clang-only
sed -i 's/-Wno-unneeded-internal-declaration//' local.mk
sed -i 's/-Wno-deprecated-register//' src/libexpr/local.mk
# Missing <cstdint> for uint32_t/uint64_t (implicit headers changed in GCC 11+)
sed -i '1i #include <cstdint>' src/libutil/serialise.hh src/libexpr/attr-set.hh
# Don't build docs (missing docbook dependencies)
sed -i '/doc\/manual/d' Makefile
'';
# Shift-count-overflow warnings in serialise.hh (32-bit time_t code paths)
env.NIX_CFLAGS_COMPILE = "-Wno-error=shift-count-overflow";
# bdw-gc C++ support (GC_throw_bad_alloc) is in separate library
env.NIX_LDFLAGS = "-lgccpp";

# Tests require a functional /nix/store
doCheck = false;
doInstallCheck = false;

meta = {
description = "Nix 1.11.x for compatibility testing";
homepage = "https://nixos.org/nix/";
license = lib.licenses.lgpl21Plus;
platforms = lib.platforms.unix;
};
}
10 changes: 10 additions & 0 deletions tests/functional/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ elif isDaemonNewer "2.29pre"; then
<<<"$out" grepQuiet -E "error: Cannot build '.*-x4\\.drv'"
<<<"$out" grepQuiet -E "Reason: 1 dependency failed."
<<<"$out" grepQuiet -E "Build failed due to failed dependency"
elif ! isDaemonNewer "2.0"; then
# Observed with Nix 1.11.16: new client with very old daemon still produces new-style messages.
# TODO: if the `else` branch (2.0 to 2.29pre) also produces new-style messages, merge these branches.
<<<"$out" grepQuiet -E "error: Cannot build '.*-x4\\.drv'"
<<<"$out" grepQuiet -E "Reason: 1 dependency failed."
else
<<<"$out" grepQuiet -E "error: 1 dependencies of derivation '.*-x4\\.drv' failed to build"
fi
Expand All @@ -211,6 +216,11 @@ test "$status" = 1
if isDaemonNewer "2.29pre"; then
<<<"$out" grepQuiet -E "error: Cannot build '.*-x4\\.drv'"
<<<"$out" grepQuiet -E "Reason: 2 dependencies failed."
elif ! isDaemonNewer "2.0"; then
# Observed with Nix 1.11.16: new client with very old daemon still produces new-style messages.
# TODO: if the `else` branch (2.0 to 2.29pre) also produces new-style messages, merge these branches.
<<<"$out" grepQuiet -E "error: Cannot build '.*-x4\\.drv'"
<<<"$out" grepQuiet -E "Reason: 2 dependencies failed."
else
<<<"$out" grepQuiet -E "error: 2 dependencies of derivation '.*-x4\\.drv' failed to build"
fi
Expand Down
7 changes: 6 additions & 1 deletion tests/functional/common/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ isDaemonNewer () {
[[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0
local requiredVersion="$1"
local daemonVersion
daemonVersion=$("$NIX_DAEMON_PACKAGE/bin/nix" daemon --version | cut -d' ' -f3)
# Nix 2.4+ has unified 'nix' command; older versions only have nix-store etc.
if [[ -x "$NIX_DAEMON_PACKAGE/bin/nix" ]]; then
daemonVersion=$("$NIX_DAEMON_PACKAGE/bin/nix" daemon --version | cut -d' ' -f3)
else
daemonVersion=$("$NIX_DAEMON_PACKAGE/bin/nix-store" --version | cut -d' ' -f3)
fi
[[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]]
}

Expand Down
16 changes: 14 additions & 2 deletions tests/functional/common/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,27 @@ gc-reserved-space = 0
substituters =
flake-registry = $TEST_ROOT/registry.json
show-trace = true
include nix.conf.extra
trusted-users = $(whoami)
EOF

cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
# 'include' directive not available in Nix 1.11. Exact version of introduction TBD.
if isDaemonNewer "2.0"; then
cat >> "$NIX_CONF_DIR"/nix.conf <<EOF
include nix.conf.extra
EOF

cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
fsync-metadata = false
extra-experimental-features = flakes
!include nix.conf.extra.not-there
EOF
else
# Inline the extra config for older daemons that don't support include
cat >> "$NIX_CONF_DIR"/nix.conf <<EOF
fsync-metadata = false
extra-experimental-features = flakes
EOF
fi

# Initialise the database.
# The flag itself does nothing, but running the command touches the store
Expand Down
6 changes: 6 additions & 0 deletions tests/functional/db-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ if [[ -z "${NIX_DAEMON_PACKAGE-}" ]]; then
skipTest "not using the Nix daemon"
fi

# --secret-key-files not available in Nix 1.11. Exact version of introduction TBD.
# TODO: skip or conditionalize individual test cases instead of skipping the whole file
if ! isDaemonNewer "2.0"; then
skipTest "Daemon too old for this test"
fi

TODO_NixOS

killDaemon
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/dyn-drv/old-daemon-error-hack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Purposely bypassing our usual common for this subgroup
source ../common.sh

# ca-derivations and dynamic-derivations not available in Nix 1.11. Exact version of introduction TBD.
requireDaemonNewerThan "2.4"

# Need backend to support text-hashing too
isDaemonNewer "2.18.0pre20230906" && skipTest "Daemon is too new"

Expand Down
4 changes: 4 additions & 0 deletions tests/functional/post-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

source common.sh

# --post-build-hook not available in Nix 1.11. Exact version of introduction TBD.
# TODO: skip or conditionalize individual test cases instead of skipping the whole file
requireDaemonNewerThan "2.0"

TODO_NixOS

clearStore
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/remote-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

source common.sh

# 'nix store info' protocol not compatible with Nix 1.11 daemon. Exact version of introduction TBD.
# TODO: skip or conditionalize individual test cases instead of skipping the whole file
requireDaemonNewerThan "2.0"

TODO_NixOS

clearStore
Expand Down
6 changes: 6 additions & 0 deletions tests/functional/user-envs-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ if isDaemonNewer "2.4pre20211005"; then
skipTest "Daemon is too new"
fi

# Manifest format with 'escaped' variable not available in Nix 1.11. Exact version of introduction TBD.
# TODO: skip or conditionalize individual test cases instead of skipping the whole file
if ! isDaemonNewer "2.0"; then
skipTest "Daemon too old for this test"
fi


killDaemon
unset NIX_REMOTE
Expand Down
Loading