1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 14:32:45 -04:00
Commit graph

505 commits

Author SHA1 Message Date
Robert Hensing a0635a80b2 printAttrs: Force item before determining whether to print multi-line 2024-07-17 13:42:05 +02:00
Robert Hensing ece334b532 tests/functional/repl: Characterize side effecting print behavior
Reported on matrix by aleksana:
https://matrix.to/#/!VRULIdgoKmKPzJZzjj:nixos.org/$7wZp5lUDTd-_u6MYo8kWWcysjtqTiQqP8dLI0RDNVVM?via=nixos.org&via=matrix.org&via=nixos.dev
2024-07-17 13:42:05 +02:00
Silvan Mosberger 9fae50ed4b Add parser test for indented strings
So that in the next commit we can see what changes about this test
2024-07-17 02:43:47 +02:00
Robert Hensing 7dce074634 tests/functional/lang: Avoid /usr/bin/env for sandbox 2024-07-16 22:43:56 +02:00
Robert Hensing f9a1d6b018 tests/functional/lang: Add post processing and remove certain line numbers 2024-07-16 17:36:30 +02:00
Robert Hensing 74698d54c8 Document builtins.derivation 2024-07-16 17:20:09 +02:00
Robert Hensing 41a03738d6 tests/functional: Also keep plain grep calls safe from newlines 2024-07-16 01:54:12 +02:00
Robert Hensing 644b97ce25 tests/functional: Make our grep* helpers reject newlines in the query
Newlines behave like *OR*; not "and then".
2024-07-16 01:41:22 +02:00
Robert Hensing f2df3f0c6c tests/vars-and-functions: Add callerPrefix helper 2024-07-16 01:40:33 +02:00
Robert Hensing 783a8341ee tests/functional: Support negative codes in expect, expectStderr 2024-07-16 01:32:54 +02:00
Goldstein 1bec90e3c4
tests/functional/repl.sh: fail test on wrong stdout
Previous test implementation assumed that grep supports newlines
in patterns. It doesn't, so tests spuriously passed, even though
some tests outputs were broken.

This patches output (and expected output) before grepping,
so there're no newlines in pattern.
2024-07-15 23:11:26 +03:00
Robert Hensing 8a855296f5 tests/function/repl: Characterise the missing doc comment behavior 2024-07-15 19:56:40 +02:00
Robert Hensing f9243eca75 tests/functional/repl.sh: Work around GHA failure 2024-07-15 19:56:40 +02:00
Robert Hensing cef11b23e8 Add missing .sh in _NIX_TEST_ACCEPT=1 message 2024-07-15 19:56:40 +02:00
Robert Hensing d4f576b0b2 nix repl: Render docs for attributes 2024-07-15 19:56:40 +02:00
Robert Hensing 7fae378835 Track doc comments and render them in :doc 2024-07-15 19:56:40 +02:00
Robert Hensing 86420753ec Merge remote-tracking branch 'upstream/master' into support-hardlinks-in-tarballs 2024-07-11 11:43:02 +02:00
Robert Hensing cfe3ee3de8
nix-shell: look up shell.nix when argument is a directory (#11057)
* Refactor: rename runEnv -> isNixShell

* Refactor: rename left -> remainingArgs

* nix-build.cc: Refactor: extract baseDir variable

* nix-build.cc: Refactor: extract sourcePath, resolvedPath variables

* nix-shell: Look for shell.nix when directory is specified

* Add legacy setting: nix-shell-always-looks-for-shell-nix

* rl-next: Add note about shell.nix lookups

* tests/functional/shell.nix: Implement runHook for dummy stdenv
2024-07-08 14:36:36 +02:00
Robert Hensing 193dd5d934 Fixup: add missing test file 2024-07-07 14:49:52 +02:00
Robert Hensing 3e424b1040 Merge branch 'nix-shell-lookup-shell-nix' into more-nix-shell 2024-07-07 14:16:15 +02:00
Robert Hensing e1106b45a3 tests/functional/nix-shell.sh: Fix Polo test for VM test
It is unclear to me why this worked when not in a VM test, but the
explanation would be in the part of nix-shell we're getting rid of
with the devShell attribute.
2024-07-07 13:03:19 +02:00
Robert Hensing 0f8a655023 tests/functional/shell.nix: Implement runHook for dummy stdenv 2024-07-07 13:02:21 +02:00
Robert Hensing 2f1fada76b Add legacy setting: nix-shell-always-looks-for-shell-nix 2024-07-07 01:22:00 +02:00
Robert Hensing 73602a7c6f nix-shell: Look for shell.nix when directory is specified 2024-07-07 01:22:00 +02:00
Robert Hensing 63262e78c7 Add opt-out: nix-shell-shebang-arguments-relative-to-script 2024-07-07 00:55:33 +02:00
Robert Hensing f5b59fbc64 Fix and extend nix-shell baseDir test 2024-07-07 00:23:22 +02:00
Robert Hensing 8838f5c746 Merge remote-tracking branch 'matthewbauer/nix-shell-relative-shebang' into more-nix-shell 2024-07-07 00:18:03 +02:00
Robert Hensing 32fb127b9c Add legacy setting: nix-shell-always-looks-for-shell-nix 2024-07-06 23:05:34 +02:00
Robert Hensing b865625a8e nix-shell: Look for shell.nix when directory is specified 2024-07-06 23:05:34 +02:00
Robert Hensing 0b901e10ee
Merge pull request #11050 from hercules-ci/issue-10677
Explain when `man` is missing
2024-07-05 22:25:38 +02:00
Jörg Thalheim 8cea1fbd97 src/nix/prefetch: fix prefetch containing current directory instead of tarball
When --unpack was used the nix would add the current directory to the
nix store instead of the content of unpacked.
The reason for this is that std::distance already consumes the iterator.
To fix this we re-instantiate the directory iterator in case the
directory only contains a single entry.
2024-07-05 19:18:49 +02:00
Robert Hensing 6ef00a503a Explain when man is missing
Have you seen this man?

Fixes #10677
2024-07-05 19:18:23 +02:00
Robert Hensing d63bd8295e assert: Report why values aren't equal 2024-07-05 16:43:48 +02:00
Eelco Dolstra 1ff186fc6e nix flake metadata: Show flake fingerprint
This is useful for testing/debugging and maybe for sharing eval caches
(since it tells you what file in ~/.cache/nix/eval-cache-v5 to copy).
2024-07-03 17:00:30 +02:00
Eelco Dolstra 6600b1c7e0 tests/functional/flakes/eval-cache.sh: Don't write a result symlink in the wrong location 2024-07-01 19:10:41 +02:00
Eelco Dolstra 10c9764c27
Merge pull request #10992 from hercules-ci/issue-10947-dont-cache-disallowed-ifd
Fix #10947; don't cache disallowed IFD
2024-07-01 11:20:27 +02:00
Robert Hensing b2c7f09b0a Fix underflow in Printer::printList
Analogous to 9b88bf8adf / three commits back
2024-06-29 14:10:58 +02:00
Robert Hensing 9b88bf8adf Fix underflow in Printer::printAttrs
The code that counts the number of elided attrs incorrectly used the
per-printer "global" attribute counter instead of a counter that
was relevant only to the current attribute set.

This bug flew under the radar because often the attribute sets aren't
nested, not big enough, or we wouldn't pay attention to the numbers.
I've noticed the issue because the difference underflowed.

Although this behavior is tested by the functional test
lang/eval-fail-bad-string-interpolation-4.nix, the underflow slipped
through review. A simpler reproducer would be as follows, but I
haven't added it to the test suite to keep it simple and marginally
faster.

```
$ nix run nix/2.23.1 -- eval --expr '"" + (let v = { a = { a = 1; b = 2; c = 1; d = 1; e = 1; f = 1; g = 1; h = 1; }; b = { a = 1; b = 1; c = 1; }; }; in builtins.deepSeq v v)'
error:
       … while evaluating a path segment
         at «string»:1:6:
            1| "" + (let v = { a = { a = 1; b = 2; c = 1; d = 1; e = 1; f = 1; g = 1; h = 1; }; b = { a = 1; b = 1; c = 1; }; }; in builtins.deepSeq v v)
             |      ^

       error: cannot coerce a set to a string: { a = { a = 1; b = 2; c = 1; d = 1; e = 1; f = 1; g = 1; h = 1; }; b = { a = 1; «4294967289 attributes elided» }; }
```
2024-06-29 13:53:05 +02:00
Robert Hensing fd94b74ee5 Fix #10947; don't cache disallowed IFD 2024-06-29 13:19:04 +02:00
Cole Helbling 9e9730ef0f Test that commit-lock-file-summary and its alias work 2024-06-28 14:53:40 -07:00
John Ericson 8a420162ab Merge branch 'master' into fix-sandbox-escape 2024-06-26 18:11:39 -04:00
Robert Hensing 7df9d6da65 Improve error messages for invalid derivation names 2024-06-25 19:41:29 +02:00
John Ericson 5c497a992b
Merge pull request #10922 from hercules-ci/functional-tests-on-nixos
Run the functional tests in a NixOS environment
2024-06-24 13:36:13 -04:00
Robert Hensing 5a7ccd6580 tests/functional: Print all args of fail() 2024-06-24 18:11:58 +02:00
Robert Hensing d4ca634508 tests/functional: Differentiate die and fail 2024-06-24 18:11:10 +02:00
Robert Hensing 602c444411 Merge remote-tracking branch 'upstream/master' into functional-tests-on-nixos 2024-06-24 18:07:21 +02:00
John Ericson 1620ad4587 Split out GlobalConfig into its own header
This makes it easier to understand the reach of global variables /
global state in the config system.
2024-06-24 11:36:21 -04:00
Robert Hensing 6f64154eea
Merge pull request #10884 from tomberek/tomberek.warn_structuredAttrs_advanced
fix: warn and document when advanced attributes will have no impact d…
2024-06-24 07:56:26 +02:00
HaeNoe 9f9984e4d0 Functional test for derivation "advanced attrs"
This tests the Nix language side of things.

We are purposely skipping most of `common.sh` because it is overkill for
this test: we don't want to have an "overfit" test environment.

Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems>
2024-06-23 21:42:56 -04:00
John Ericson 490ca93cf8 Factor out a bit more language testings infra
Will be used in a second test after `lang.sh`.
2024-06-23 15:33:45 -04:00
Eelco Dolstra d54590fdf3 Fix --no-sandbox
When sandboxing is disabled, we cannot put $TMPDIR underneath an
inaccessible directory.
2024-06-21 17:06:19 +02:00
Théophane Hufschmitt 1d3696f0fb Run the builds in a daemon-controled directory
Instead of running the builds under
`$TMPDIR/{unique-build-directory-owned-by-the-build-user}`, run them
under `$TMPDIR/{unique-build-directory-owned-by-the-daemon}/{subdir-owned-by-the-build-user}`
where the build directory is only readable and traversable by the daemon user.

This achieves two things:

1. It prevents builders from making their build directory world-readable
   (or even writeable), which would allow the outside world to interact
   with them.
2. It prevents external processes running as the build user (either
   because that somehow leaked, maybe as a consequence of 1., or because
   `build-users` isn't in use) from gaining access to the build
   directory.
2024-06-21 17:06:19 +02:00
Robert Hensing d9684664c8 Revert "tests/functional/common/init.sh: Use parentheses around negation"
ShellCheck doesn't want us to add extra parentheses for show.

This reverts commit 7c9f3eeef8.
2024-06-20 22:31:32 +02:00
Robert Hensing dcee46a0ef Apply suggestions from code review
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2024-06-20 14:54:11 +02:00
Robert Hensing 7c9f3eeef8 tests/functional/common/init.sh: Use parentheses around negation
roberth: Not strictly necessary, but probably a good habit

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2024-06-20 14:54:11 +02:00
Robert Hensing 648302b833 tests/functional: Enable more tests in NixOS VM 2024-06-20 14:54:11 +02:00
Robert Hensing 8557d79650 tests/functional: Skip tests that don't work in NixOS environment yet 2024-06-20 14:54:11 +02:00
Robert Hensing 211aec473e tests/functional/timeout.sh: Find missing test case
This reproduces an instance of
https://github.com/NixOS/nix/issues/4813
2024-06-20 14:54:11 +02:00
Robert Hensing 439022c5ac tests: Add hydraJobs.tests.functional_* 2024-06-20 14:54:11 +02:00
Robert Hensing 316b58dd5f tests/shell.sh: Check that env is mostly unmodified 2024-06-17 17:03:58 +02:00
Robert Hensing 68b8a28bc4 tests/run.sh: Check that env is mostly unmodified 2024-06-17 17:03:58 +02:00
Eelco Dolstra 1dc7c8e599 eval-fail-infinite-recursion-lambda: Reduce recursion depth
This prevents the test from failing in environments with a smaller
configured stack size.
2024-06-13 13:55:42 +02:00
John Ericson 33241887d1 More quote coalescing 2024-06-12 17:47:54 -04:00
John Ericson d8ae28617d Try to fix quotes that don't go to end with sed 2024-06-12 17:41:16 -04:00
Cameron Dart 2d467b4731 housekeeping: shellcheck for tests/functional/import-derivation.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 1c93360989 housekeeping: shellcheck for tests/functional/hash-path.sh 2024-06-12 17:41:16 -04:00
Cameron Dart d1c476865a housekeeping: shellcheck for tests/functional/gc-runtime.sh 2024-06-12 17:41:16 -04:00
Cameron Dart cd46ec17f9 housekeeping: shellcheck for tests/functional/function-trace.sh 2024-06-12 17:41:16 -04:00
Cameron Dart b764dd9aa4 housekeeping: shellcheck for tests/functional/flakes/unlocked-override.sh 2024-06-12 17:41:16 -04:00
Cameron Dart e1ce349d05 housekeeping: shellcheck for tests/functional/flakes/search-root.sh 2024-06-12 17:41:16 -04:00
Cameron Dart b9768b4872 housekeeping: shellcheck for tests/functional/flakes/mercurial.sh 2024-06-12 17:41:16 -04:00
Cameron Dart c7b3468968 housekeeping: shellcheck for tests/functional/flakes/inputs.sh 2024-06-12 17:41:16 -04:00
Cameron Dart d95adb531e housekeeping: shellcheck for tests/functional/flakes/init.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 71d5baca47 housekeeping: shellcheck for tests/functional/flakes/flake-in-submodule.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 3b853e795b housekeeping: shellcheck for tests/functional/flakes/circular.sh 2024-06-12 17:41:16 -04:00
Cameron Dart ece86b7191 housekeeping: shellcheck for tests/functional/flakes/bundle.sh 2024-06-12 17:41:16 -04:00
Cameron Dart ee57c610ae housekeeping: shellcheck for tests/functional/flakes/build-paths.sh 2024-06-12 17:41:16 -04:00
Cameron Dart d81fd4a1c3 housekeeping: shellcheck for tests/functional/flakes/absolute-attr-paths.sh 2024-06-12 17:41:16 -04:00
Cameron Dart ae6a842c55 housekeeping: shellcheck for tests/functional/filter-source.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 224f5515b9 housekeeping: shellcheck for tests/functional/fetchTree-file.sh
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2024-06-12 17:41:16 -04:00
Cameron Dart f0492a6197 housekeeping: shellcheck for tests/functional/fetchPath.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 823d53c643 housekeeping: shellcheck for tests/functional/experimental-features.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 1c1abefdd2 housekeeping: shellcheck for tests/functional/dyn-drv/text-hashed-output.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 847842c4bb housekeeping: shellcheck for tests/functional/derivation-json.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 58a653dcc6 housekeeping: shellcheck for tests/functional/compression-levels.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 48520cb71e housekeeping: shellcheck for tests/functional/chroot-store.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 63272235e2 housekeeping: shellcheck for tests/functional/case-hacks.sh
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2024-06-12 17:41:16 -04:00
Cameron Dart 4f04006bc1 housekeeping: shellcheck for tests/functional/check-reqs.sh 2024-06-12 17:41:16 -04:00
Cameron Dart d7bb5bde48 housekeeping: shellcheck for tests/functional/check-refs.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 259b502773 housekeeping: shellcheck for tests/functional/ca/substitute.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 04876c39e4 housekeeping: shellcheck for tests/functional/ca/signatures.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 8f85537629 housekeeping: shellcheck for tests/functional/ca/nix-run.sh 2024-06-12 17:41:16 -04:00
Cameron Dart deacc421eb housekeeping: shellcheck for tests/functional/ca/nix-copy.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 195c0da849 housekeeping: shellcheck for tests/functional/ca/duplicate-realisation-in-closure.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 2dfbba3e5e housekeeping: shellcheck for tests/functional/ca/derivation-json.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 627176fd54 housekeeping: shellcheck for tests/functional/ca/build.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 80c44138cb housekeeping: shellcheck for tests/functional/ca/build-cache.sh
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2024-06-12 17:41:16 -04:00
Cameron Dart c127625095 housekeeping: shellcheck for tests/functional/build-dry.sh 2024-06-12 17:41:16 -04:00
Cameron Dart f615489e0e housekeeping: shellcheck for tests/functional/build-delete.sh 2024-06-12 17:41:16 -04:00
Cameron Dart 7186c68f75 housekeeping: shellcheck for tests/functional/brotli.sh
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2024-06-12 17:41:15 -04:00
Cameron Dart aeed835a2e housekeeping: shellcheck for tests/functional/binary-cache.sh
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2024-06-12 17:41:08 -04:00
Cameron Dart 4a28ba7877 housekeeping: shellcheck for tests/functional/binary-cache-build-remote.sh 2024-06-12 16:58:25 -04:00
Cameron Dart 7738b295e5 housekeeping: shellcheck for tests/functional/bash-profile.sh 2024-06-12 16:58:25 -04:00
Eelco Dolstra bd37a70d8f
Update tests/functional/tarball.sh
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-06-11 19:39:42 +02:00
Eelco Dolstra 35bdb9cee7 Support hard links in tarballs
Fixes #10395.
2024-06-11 16:05:57 +02:00
Robert Hensing de3fd52a95 Add tests/f/lang/eval-okay-derivation-legacy 2024-06-10 16:31:46 +02:00
Robert Hensing da82d67022 builtins.warn: Require string argument
... so that we may perhaps later extend the interface.
Note that Nixpkgs' lib.warn already requires a string coercible
argument, so this is reasonable. Also note that string coercible
values aren't all strings, but in practice, for warn, they are.
2024-06-03 16:24:21 +02:00
Robert Hensing 2d4c9d8f4a Add builtins.warn 2024-06-03 16:24:21 +02:00
John Ericson 1e99f324d9 Fix shellcheck issue
8b86f415c1 was merged from a CI run that
predated the new linting.
2024-06-03 09:36:48 -04:00
Eelco Dolstra ecfad6a828
Merge pull request #10564 from edolstra/remove-forceErrors
AttrCursor: Remove forceErrors
2024-06-03 15:30:01 +02:00
John Ericson 84c65135a5 ValidPathInfo JSON format should use null not omit field
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-06-03 08:21:22 -04:00
Robert Hensing f8bd4ba561
Merge pull request #10827 from SkamDart/skamdart/functional-add-sc
housekeeping: shellcheck test/functional/add.sh
2024-06-03 12:31:39 +02:00
Cameron Dart 6a507f5d3b housekeeping: shellcheck test/functional/add.sh 2024-06-02 13:41:51 -07:00
Ivan Trubach 68090d7ff1 Fix empty outputsToInstall for InstallableAttrPath
Fixes assertion failure if outputsToInstall is empty by defaulting to the "out"
output. That is, behavior between the following commands should be consistent:

	$ nix build --no-link --json .#nothing-to-install-no-out
	error: derivation '/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-nothing-to-install-no-out.drv' does not have wanted outputs 'out'

	$ nix build --no-link --file default.nix --json nothing-to-install-no-out
	error: derivation '/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-nothing-to-install-no-out.drv' does not have wanted outputs 'out'

Real-world example of this issue:

	$ nix build --json .#.legacyPackages.aarch64-linux.texlive.pkgs.iwona
	error: derivation '/nix/store/dj0h6b0pnlnan5nidnhqa0bmzq4rv6sx-iwona-0.995b.drv' does not have wanted outputs 'out'

	$ git rev-parse HEAD
	eee33247cf6941daea8398c976bd2dda7962b125
	$ nix build --json --file . texlive.pkgs.iwona
	nix: src/libstore/outputs-spec.hh:46: nix::OutputsSpec::Names::Names(std::set<std::__cxx11::basic_string<char> >&&): Assertion `!empty()' failed.
	Aborted (core dumped)
2024-06-02 14:26:18 +03:00
Robert Hensing 802b4e403b
Merge pull request #10814 from Mic92/fix-nix-edit
Fix nix edit
2024-05-31 13:30:24 +02:00
Jörg Thalheim 69c159811e add regression test for nix edit 2024-05-31 12:58:47 +02:00
Robert Hensing c692f6af13 nix env shell: Move from nix shell, add shorthand alias 2024-05-30 19:41:58 +02:00
John Ericson 10f864c5ae Ensure all functional scripts are (a) executable (b) have shebang
This is good for shebang, and also good for future build system
simplifications
2024-05-28 12:46:24 -04:00
John Ericson 2e12b58126 Shellcheck some test scripts
Progress on #10795
2024-05-28 12:32:22 -04:00
John Ericson 567265ae67 Start getting all shell scripts passing shellcheck
Like with the formatter, we are blacklisting most files by default.

Do a few files to get us started, and get a sense of what this looks
like.
2024-05-27 22:39:56 -04:00
Eelco Dolstra 8b86f415c1 Add test for the evaluation cache 2024-05-24 16:34:49 +02:00
John Ericson f923ed6b6a Require drvPath attribute to end with .drv
Fixes #4977
2024-05-22 12:50:24 -04:00
John Ericson 470c0501eb Ensure all store types support "real" URIs
In particular `local://<path>` and `unix://` (without any path) now
work, and mean the same things as `local` and `daemon`, respectively. We
thus now have the opportunity to desguar `local` and `daemon` early.

This will allow me to make a change to
https://github.com/NixOS/nix/pull/9839 requested during review to
desugar those earlier.

Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2024-05-21 11:56:40 -04:00
Robert Hensing e4be8abe42
Merge pull request #10701 from cole-h/nix-command-warn-unknown-settings
Warn on unknown settings when the first positional is an argument
2024-05-20 15:15:13 +02:00
Maximilian Bosch 19720d733f nix3-build: show all FOD errors with --keep-going
Basically I'd expect the same behavior as with `nix-build`, i.e.
with `--keep-going` the hash-mismatch error of each failing
fixed-output derivation is shown.

The approach is derived from `Store::buildPaths` (`entry-point.cc`):
instead of throwing the first build-result, check if there are any build
errors and if so, display all of them and throw after that.

Unfortunately, the BuildResult struct doesn't have an `ErrorInfo`
(there's a FIXME for that at least), so I have to construct my own here.
This is a rather cheap bugfix and I decided against touching too many
parts of libstore for that (also I don't know if that's in line with the
ongoing refactoring work).

Closes https://git.lix.systems/lix-project/lix/issues/302

Change-Id: I378ab984fa271e6808c6897c45e0f070eb4c6fac
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
2024-05-17 18:48:52 +02:00
Eelco Dolstra 3026613893
Merge pull request #10675 from edolstra/zip-symlinks
Handle zip files containing symlinks
2024-05-15 22:07:22 +02:00
Cole Helbling 06e13465c5 tests/functional: test both clis warn on unknown settings 2024-05-15 12:25:03 -07:00
Eelco Dolstra 1da18e85ba tests/functional/common/init.sh: Make $TEST_ROOT writable before removing it
$TEST_ROOT typically contains read-only files/directories (e.g. the
Nix store). So we have to make it writable first.
2024-05-14 16:23:08 +02:00
Valentin Gagarin 7822ecbadf tests: always clean the test directory
previously the test directory could have been left untouched before executing
a test when `init.sh` was not run - and sometimes it isn't
supposed to be run - which made the test suite highly stateful and thus
behaving surprisingly on multiple runs.
2024-05-13 15:19:49 +02:00
Valentin Gagarin 33ca905cdb tests: simplify initialisation and wiring
pararameterisation is not actually needed the way things are currently
set up, and it confused me when trying to understand what the code does.

all but one test sources vars-and-functions.sh, which nominally only
defines variables, but in practice is always coupled with the actual
initialisation. while the cleaner way of making this more legible would
be to source variables and initialisation separately, this would produce
a huge diff.

the change requires a few small fixes to keep the tests working:

- only create test home directory during initialisation

  that vars-and-functions.sh wrote to the file system seems not write

- fix creation of the test directory

  due to statefulness, the test home directory was implicitly creating
  the test root, too. decoupling that made it apparent that this was
  probably not intentional, and certainly confusing.

- only source vars-and-functions.sh if init.sh is not needed

  there is one test case that only needs a helper function but no
  initialisation side effects

- remove some unnecessary cleanups and split parts of re-used test code

  there were confusing bits in how initialisation code was repurposed,
  which break if trying to refactor the outer layers naively...
2024-05-13 15:19:49 +02:00
Eelco Dolstra 9951e14ae0 Handle zip files containing symlinks
In streaming mode, libarchive doesn't handle symlinks in zip files
correctly. So write the entire file to disk so libarchive can access
it in random-access mode.

Fixes #10649. This was broken in cabee98152.
2024-05-09 19:33:09 +02:00
Eelco Dolstra 79c7d6205c Support unit prefixes in configuration settings
E.g. you can now say `--min-free 1G`.
2024-05-08 21:11:09 +02:00
Eelco Dolstra da3381d51f
Merge pull request #10465 from edolstra/remove-locked
Fetcher cache cleanups
2024-05-06 21:32:26 +02:00
Théophane Hufschmitt 9bd1191fcc libstore: check additionalSandboxProfile
Make sure that `extraSandboxProfile` is set before we check whether it's
empty or not (in the `sandbox=true` case).

Also adds a test case for this.

Co-Authored-By: Artemis Tosini <lix@artem.ist>
Co-Authored-By: Eelco Dolstra <edolstra@gmail.com>
2024-05-06 17:37:08 +02:00
Eelco Dolstra 1f41682217
Update tests/functional/flakes/flakes.sh
Co-authored-by: John Ericson <git@JohnEricson.me>
2024-04-30 18:10:16 +02:00
Eelco Dolstra f29a220b70 Test that the root of a tree produces /nix/store/<hash1>-<hash2>-source 2024-04-30 17:25:35 +02:00
Eelco Dolstra 503be57bbd Test baseNameOf behaviour on the root of a flake 2024-04-30 15:43:33 +02:00
Eelco Dolstra 458441c637 Test dirOf behaviour on the root of a flake 2024-04-30 15:34:38 +02:00
Eelco Dolstra ff107d9d03 Input::fetchToStore(): Don't try to substitute
Having a narHash doesn't mean that we have the other attributes
returned by the fetcher (such as lastModified or rev). For instance,

   $ nix flake metadata github:NixOS/patchelf/7c2f768bf9601268a4e71c2ebe91e2011918a70f
   Last modified: 2024-01-15 10:51:22

but

   $ nix flake metadata github:NixOS/patchelf/7c2f768bf9601268a4e71c2ebe91e2011918a70f?narHash=sha256-PPXqKY2hJng4DBVE0I4xshv/vGLUskL7jl53roB8UdU%3D
   (does not print a "Last modified")

The latter only happens if the store path already exists or is
substitutable, which made this impure behaviour unpredictable.

Fixes #10601.
2024-04-26 16:41:33 +02:00
Robert Hensing 750bcaa330 Fix fetchGit nested submodules 2024-04-22 16:41:40 +02:00
Théophane Hufschmitt d2a07a96ba
Merge pull request #10467 from edolstra/nix-shell-symlink
nix shell: Handle output paths that are symlinks
2024-04-16 12:31:14 +02:00
Eelco Dolstra d084c1cb41 Remove the "locked" flag from the fetcher cache
This also reworks the Mercurial fetcher (which was still using the
old cache interface) to have two distinct cache mappings:

* A ref-to-rev mapping, which is store-independent.
* A rev-to-store-path mapping.
2024-04-15 13:03:27 +02:00
Théophane Hufschmitt cef677ddbc Test the inclusion of transitive symlinks in the sandbox 2024-04-12 16:10:22 +02:00
Théophane Hufschmitt acbb1523c1 Fix the access of symlinks to host files in the sandbox
https://github.com/NixOS/nix/pull/10456 fixed the addition of symlink
store paths to the sandbox, but also made it so that the hardcoded
sandbox paths (like `/etc/hosts`) were now bind-mounted without
following the possible symlinks. This made these files unreadable if
there were symlinks (because the sandbox would now contain a symlink to
an unreachable file rather than the underlying file).
In particular, this broke FOD derivations on NixOS as `/etc/hosts` is a
symlink there.

Fix that by canonicalizing all these hardcoded sandbox paths before
adding them to the sandbox.
2024-04-12 15:57:53 +02:00
Théophane Hufschmitt da1e977bf4
Merge pull request #10456 from NixOS/fixpermdeniedbind
Fix adding symlink to the sandbox paths
2024-04-11 13:41:49 +02:00
Eelco Dolstra 26a4688a86 nix shell: Test that store paths cannot link outside of the store 2024-04-11 11:06:35 +02:00
Eelco Dolstra 9d50f57fa3 Doh 2024-04-11 09:00:47 +02:00
Théophane Hufschmitt def00d7b52
Merge pull request #10455 from tie/structured-attrs-get-env
Do not rely on $stdenv/setup to set output variables
2024-04-11 06:48:36 +02:00
Eelco Dolstra 85b9f4ef4f nix shell: Handle output paths that are symlinks
This requires moving resolveSymlinks() into SourceAccessor. Also, it
requires LocalStoreAccessor::maybeLstat() to work on parents of the
store (to avoid an error like "/nix is not in the store").

Fixes #10375.
2024-04-10 23:49:19 +02:00
Ivan Trubach 664532c533 Do not rely on $stdenv/setup to set output variables
Instead of relying on setup script to set output variables when
structured attributes are enabled, iterate over the values of an
outputs associative array.

See also
374fa3532e/pkgs/stdenv/generic/setup.sh (L23-L26)
2024-04-10 19:50:19 +03:00