Compare commits

...
Author SHA1 Message Date
Robert Hensing 7bd3f3b324 Add nix-all-output-paths
This implements the `fallback-paths.nix` format in NixOS
2024-09-23 03:07:09 +02:00
Eelco Dolstra ca3fc1693b Merge pull request #11548 from DeterminateSystems/fix-zipAttrsWith-gc
Fix missing GC root in zipAttrsWith
2024-09-19 21:02:36 +02:00
Eelco DolstraandRobert Hensing 4449b0da74 Use HAVE_BOEHMGC
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-09-19 19:52:47 +02:00
Eelco Dolstra 0c2fdd2f3c Fix missing GC root in zipAttrsWith
My SNAFU was that I assumed that all the `Value *`s we put in
`attrsSeen` are already reachable (which they are), but I forgot about
the `elems` pointer in `ListBuilder`.

Fixes #11547.
2024-09-19 19:16:31 +02:00
Eelco Dolstra 9ea29ea517 Merge pull request #11540 from NixOS/meson-arm-atomic
nix-util / meson: Add -latomic on arm
2024-09-19 16:09:14 +02:00
Eelco Dolstra cd5fc45524 Merge pull request #11541 from noamraph/fix-nix-profile-sh
nix-profile.sh.in: fix envvar condition
2024-09-19 14:32:23 +02:00
Eelco Dolstra e60b90192a Merge pull request #11538 from NixOS/detect-close_range
Use close_range when available
2024-09-19 13:48:27 +02:00
Valentin Gagarin a45a7e8011 Merge pull request #11528 from Mic92/mergify-2
mergify: enable merge-queue for backports
2024-09-19 11:29:52 +02:00
Noam Yorav-Raphael 97fffd8765 nix-profile.sh.in: fix envvar condition 2024-09-19 07:20:04 +03:00
Robert Hensing 3df1658ba1 Merge pull request #11539 from NixOS/fix-installer-tests
Revert "tests.installer: Load profile with -o unset"
2024-09-19 00:04:09 +02:00
Robert Hensing 56b8911766 nix-util / meson: Add -latomic on arm
I couldn't get the test program to work correctly after many attempts,
so let's just unblock this without making it perfect.
2024-09-19 00:01:24 +02:00
Robert Hensing c75907e47b Revert "tests.installer: Load profile with -o unset"
I must have made a mistake while testing this, because nounset does
not work on any of the distributions.

This reverts commit 2f0db04da0.
2024-09-18 23:06:01 +02:00
Robert Hensing 5c87c40a5e Use close_range when available
This fixes the FreeBSD build of nix-util
2024-09-18 22:42:44 +02:00
Eelco Dolstra 59acf3b75c Merge pull request #11532 from Mic92/macos-test-fix
tests/functional/shell: fix test in macOS devshell
2024-09-18 21:43:49 +02:00
Eelco Dolstra 96ee5450d9 Merge pull request #11529 from DeterminateSystems/test-ifd-in-chroot
Test IFD/filterSource in chroot stores
2024-09-18 21:20:04 +02:00
Valentin Gagarin 0f5c37c242 Merge pull request #11530 from Mic92/flake-archive 2024-09-18 20:58:06 +02:00
Jörg Thalheim 04a47e93f6 tests/functional/shell: fix test in macOS devshell 2024-09-18 20:51:15 +02:00
Eelco Dolstra a673084733 Fix tests 2024-09-18 19:06:48 +02:00
Eelco Dolstra d772a8b3dc shellcheck 2024-09-18 18:05:08 +02:00
Jörg Thalheim f0a4f19087 add description + example for nix flake archive
Update src/nix/flake-archive.md

Update src/nix/flake-archive.md
2024-09-18 17:31:40 +02:00
Eelco Dolstra 8690b6f138 Test IFD/filterSource in a chroot
Relevant to #11503.
2024-09-18 12:42:20 +02:00
Jörg Thalheim 0624cf0f59 mergify: enable merge-queue for backports 2024-09-18 08:46:07 +02:00
Eelco Dolstra ee3f0b7a8b Rename import-derivation -> import-from-derivation 2024-09-17 16:56:40 +02:00
21 changed files with 177 additions and 58 deletions

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ queue_rules:
pull_request_rules:
- name: merge using the merge queue
conditions:
- base=master
- base~=master|.+-maintenance
- label~=merge-queue|dependencies
actions:
queue: {}
+1 -1
View File
@@ -86,7 +86,7 @@ static char buf[1024];]],
AC_LANG_POP(C++)
AC_CHECK_FUNCS([statvfs pipe2])
AC_CHECK_FUNCS([statvfs pipe2 close_range])
# Check for lutimes, optionally used for changing the mtime of
+4
View File
@@ -223,6 +223,10 @@
default = self.packages.${system}.nix-ng;
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
nix-all-output-paths = nixpkgsFor.${system}.native.callPackage ./packaging/nix-all-output-paths.nix {
packages =
lib.mapAttrs (system: packages: packages.nix) self.packages;
};
}
# We need to flatten recursive attribute sets of derivations to pass `flake check`.
// flatMapAttrs
+1 -1
View File
@@ -508,7 +508,7 @@
''^tests/functional/ca/concurrent-builds\.sh$''
''^tests/functional/ca/eval-store\.sh$''
''^tests/functional/ca/gc\.sh$''
''^tests/functional/ca/import-derivation\.sh$''
''^tests/functional/ca/import-from-derivation\.sh$''
''^tests/functional/ca/new-build-cmd\.sh$''
''^tests/functional/ca/nix-shell\.sh$''
''^tests/functional/ca/post-hook\.sh$''
+48
View File
@@ -0,0 +1,48 @@
{ lib, formats, nix, packages, stdenv, ... }:
let
randomPick = packages."x86_64-linux";
in
stdenv.mkDerivation {
version = randomPick.version;
pname = "nix-all-output-paths";
passAsFile = [ "content" ];
nativeBuildInputs = [ nix ];
json = (formats.json {}).generate "all-output-paths.json" (lib.mapAttrs (name: pkg: "${lib.getBin pkg}") packages);
nix = ''
{
${
lib.concatStringsSep "\n " (
lib.mapAttrsToList
(name: pkg: "${lib.strings.escapeNixIdentifier name} = ${lib.strings.escapeNixString "${lib.getBin pkg}"};")
packages
)
}
}
'';
buildCommand = ''
mkdir -p $out
cp $json $out/all-output-paths.json
echo "$nix" > $out/all-output-paths.nix
mkdir -p $out/nix-support
{
echo "file all-output-paths $out/all-output-paths.json"
echo "file all-output-paths-nix-deprecated $out/all-output-paths.nix"
} >> $out/nix-support/hydra-build-products
r=$(nix-instantiate --store dummy:// --expr --eval --json \
'builtins.fromJSON (builtins.readFile '$out'/all-output-paths.json) == import '$out'/all-output-paths.nix')
if ! [[ $r == "true" ]]; then
echo "The generated Nix file does not match the JSON file"
echo "Nix file: $out/all-output-paths.nix"
cat -n $out/all-output-paths.nix
echo "JSON file: $out/all-output-paths.json"
cat -n $out/all-output-paths.json
exit 1
fi
'';
meta = {
description = "A lookup file that gives a store path containing the Nix package manager for all supported system types";
};
}
+2 -2
View File
@@ -1,9 +1,9 @@
# This file is tested by tests/installer/default.nix.
if [ -n "$HOME" ] && [ -n "$USER" ]; then
if [ -n "${HOME-}" ] && [ -n "${USER-}" ]; then
# Set up the per-user profile.
if [ -n "$NIX_STATE_HOME" ]; then
if [ -n "${NIX_STATE_HOME-}" ]; then
NIX_LINK="$NIX_STATE_HOME/profile"
else
NIX_LINK="$HOME/.nix-profile"
+4
View File
@@ -3136,7 +3136,11 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value * * arg
std::optional<ListBuilder> list;
};
#if HAVE_BOEHMGC
std::map<Symbol, Item, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, Item>>> attrsSeen;
#else
std::map<Symbol, Item> attrsSeen;
#endif
state.forceFunction(*args[0], pos, "while evaluating the first argument passed to builtins.zipAttrsWith");
state.forceList(*args[1], pos, "while evaluating the second argument passed to builtins.zipAttrsWith");
+9
View File
@@ -28,6 +28,7 @@ subdir('build-utils-meson/subprojects')
# HAVE_LUTIMES 1`. The `#define` is unconditional, 0 for not found and 1
# for found. One therefore uses it with `#if` not `#ifdef`.
check_funcs = [
'close_range',
# Optionally used for changing the mtime of symlinks.
'lutimes',
# Optionally used for creating pipes on Unix
@@ -50,6 +51,14 @@ endforeach
subdir('build-utils-meson/threads')
# Check if -latomic is needed
# This is needed for std::atomic on some platforms
# We did not manage to test this reliably on all platforms, so we hardcode
# it for now.
if host_machine.cpu_family() == 'arm'
deps_other += cxx.find_library('atomic')
endif
if host_machine.system() == 'windows'
socket = cxx.find_library('ws2_32')
deps_other += socket
+4 -1
View File
@@ -121,10 +121,13 @@ void Pipe::create()
//////////////////////////////////////////////////////////////////////
#if __linux__ || __FreeBSD__
// In future we can use a syscall wrapper, but at the moment musl and older glibc version don't support it.
static int unix_close_range(unsigned int first, unsigned int last, int flags)
{
#if !HAVE_CLOSE_RANGE
return syscall(SYS_close_range, first, last, (unsigned int)flags);
#else
return close_range(first, last, flags);
#endif
}
#endif
+13 -1
View File
@@ -22,8 +22,20 @@ R""(
# nix flake archive --json --dry-run nixops
```
* Upload all flake inputs to a different machine for remote evaluation
```
# nix flake archive --to ssh://some-machine
```
On the remote machine the flake can then be accessed via its store path. That's computed like this:
```
# nix flake metadata --json | jq -r '.path'
```
# Description
FIXME
Copy a flake and all its inputs to a store. This is useful i.e. to evaluate flakes on a different host.
)""
@@ -2,5 +2,5 @@ source common.sh
export NIX_TESTS_CA_BY_DEFAULT=1
cd .. && source import-derivation.sh
cd .. && source import-from-derivation.sh
+1 -1
View File
@@ -7,7 +7,7 @@ ca-tests := \
$(d)/duplicate-realisation-in-closure.sh \
$(d)/eval-store.sh \
$(d)/gc.sh \
$(d)/import-derivation.sh \
$(d)/import-from-derivation.sh \
$(d)/new-build-cmd.sh \
$(d)/nix-copy.sh \
$(d)/nix-run.sh \
+1 -1
View File
@@ -16,7 +16,7 @@ suites += {
'duplicate-realisation-in-closure.sh',
'eval-store.sh',
'gc.sh',
'import-derivation.sh',
'import-from-derivation.sh',
'new-build-cmd.sh',
'nix-copy.sh',
'nix-run.sh',
-26
View File
@@ -1,26 +0,0 @@
with import ./config.nix;
let
bar = mkDerivation {
name = "bar";
builder = builtins.toFile "builder.sh"
''
echo 'builtins.add 123 456' > $out
'';
};
value =
# Test that pathExists can check the existence of /nix/store paths
assert builtins.pathExists bar;
import bar;
in
mkDerivation {
name = "foo";
builder = builtins.toFile "builder.sh"
''
echo -n FOO${toString value} > $out
'';
}
-14
View File
@@ -1,14 +0,0 @@
#!/usr/bin/env bash
source common.sh
clearStoreIfPossible
if nix-instantiate --readonly-mode ./import-derivation.nix; then
echo "read-only evaluation of an imported derivation unexpectedly failed"
exit 1
fi
outPath=$(nix-build ./import-derivation.nix --no-out-link)
[ "$(cat "$outPath")" = FOO579 ]
@@ -0,0 +1,33 @@
with import ./config.nix;
rec {
bar = mkDerivation {
name = "bar";
builder = builtins.toFile "builder.sh"
''
echo 'builtins.add 123 456' > $out
'';
};
value =
# Test that pathExists can check the existence of /nix/store paths
assert builtins.pathExists bar;
import bar;
result = mkDerivation {
name = "foo";
builder = builtins.toFile "builder.sh"
''
echo -n FOO${toString value} > $out
'';
};
addPath = mkDerivation {
name = "add-path";
src = builtins.filterSource (path: type: true) result;
builder = builtins.toFile "builder.sh"
''
echo -n BLA$(cat $src) > $out
'';
};
}
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
source common.sh
TODO_NixOS
clearStoreIfPossible
if nix-instantiate --readonly-mode ./import-from-derivation.nix -A result; then
echo "read-only evaluation of an imported derivation unexpectedly failed"
exit 1
fi
outPath=$(nix-build ./import-from-derivation.nix -A result --no-out-link)
[ "$(cat "$outPath")" = FOO579 ]
# FIXME: the next tests are broken on CA.
if [[ -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
exit 0
fi
# Test filterSource on the result of a derivation.
outPath2=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link)
[[ "$(cat "$outPath2")" = BLAFOO579 ]]
# Test that IFD works with a chroot store.
if canUseSandbox; then
store2="$TEST_ROOT/store2"
store2_url="$store2?store=$NIX_STORE_DIR"
# Copy the derivation outputs to the chroot store to avoid having
# to actually build anything, as that would fail due to the lack
# of a shell in the sandbox. We only care about testing the IFD
# semantics.
for i in bar result addPath; do
nix copy --to "$store2_url" --no-check-sigs "$(nix-build ./import-from-derivation.nix -A "$i" --no-out-link)"
done
clearStore
outPath_check=$(nix-build ./import-from-derivation.nix -A result --no-out-link --store "$store2_url")
[[ "$outPath" = "$outPath_check" ]]
[[ ! -e "$outPath" ]]
[[ -e "$store2/nix/store/$(basename "$outPath")" ]]
outPath2_check=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link --store "$store2_url")
[[ "$outPath2" = "$outPath2_check" ]]
fi
+1 -1
View File
@@ -88,7 +88,7 @@ nix_tests = \
why-depends.sh \
derivation-json.sh \
derivation-advanced-attributes.sh \
import-derivation.sh \
import-from-derivation.sh \
nix_path.sh \
nars.sh \
placeholders.sh \
+1 -1
View File
@@ -157,7 +157,7 @@ suites = [
'why-depends.sh',
'derivation-json.sh',
'derivation-advanced-attributes.sh',
'import-derivation.sh',
'import-from-derivation.sh',
'nix_path.sh',
'nars.sh',
'placeholders.sh',
+2
View File
@@ -31,11 +31,13 @@ env > $TEST_ROOT/expected-env
nix shell -f shell-hello.nix hello -c env > $TEST_ROOT/actual-env
# Remove/reset variables we expect to be different.
# - PATH is modified by nix shell
# - we unset TMPDIR on macOS if it contains /var/folders
# - _ is set by bash and is expectedf to differ because it contains the original command
# - __CF_USER_TEXT_ENCODING is set by macOS and is beyond our control
sed -i \
-e 's/PATH=.*/PATH=.../' \
-e 's/_=.*/_=.../' \
-e '/^TMPDIR=\/var\/folders\/.*/d' \
-e '/^__CF_USER_TEXT_ENCODING=.*$/d' \
$TEST_ROOT/expected-env $TEST_ROOT/actual-env
sort $TEST_ROOT/expected-env > $TEST_ROOT/expected-env.sorted
-6
View File
@@ -217,16 +217,10 @@ let
$ssh <<EOF
set -ex
# enable nounset while loading the profile
# this may or may not work on all distros, depending on the quality of their scripts
set -u
# FIXME: get rid of this; ideally ssh should just work.
source ~/.bash_profile || true
source ~/.bash_login || true
source ~/.profile || true
set +u
source /etc/bashrc || true
nix-env --version