1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00
Commit graph

3220 commits

Author SHA1 Message Date
Jörg Thalheim
53ac49f72c
Merge pull request #13741 from xokdvium/toml-timestamps
libexpr: Canonicalize TOML timestamps for toml11 > 4.0
2025-08-13 21:22:15 +02:00
Leandro Reina
ccf658ed5c
Fix Git LFS SSH issues
* Adds support for NIX_SSHOPTS
* Properly uses the parsed port from URL (fixes #13337)
* Don't guess the HTTP endpoint, use the response of git-lfs-authenticate
* Add an SSH Git LFS test
* Removed some unused test code
2025-08-13 21:04:29 +03:00
Sergei Zimmerman
7ed0229d1a
tests/functional/lang: Add more tests for TOML timestamps
Current test suite doesn't cover the subsecond formatting at
all and toml11 is quite finicky with that. We should at the very
least test its behavior to avoid silent breakages on updates.
2025-08-12 14:28:39 +03:00
Sergei Zimmerman
e8e9376a7b
libfetchers: Remove badGitRefRegex and use libgit2 for reference validation
Fixes usage of `#` symbol in the reference name.
This also seems to identify several deficiencies in the libgit2 refname
validation code wrt to DEL symbol and a singular `@` symbol [1].

[1]: https://git-scm.com/docs/git-check-ref-format#_description
2025-08-11 02:38:45 +03:00
Farid Zakaria
bf320465ae
Make functional tests depend on nix binary so they auto recompile
With this I'm able to do a fresh config + meson test with all dependencies
correctly propagated.

Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
2025-08-08 03:18:38 +03:00
Sergei Zimmerman
385e2c3542
meson: Apply formatting universally
Now that we have applied the [1] patch, the diff is much
nicer and less noisy.

[1]: https://www.github.com/mesonbuild/meson/pull/14861
2025-08-07 02:58:29 +03:00
Sergei Zimmerman
bf80696ed9
meson: Get rid of multiline array formatting hack 2025-08-07 02:57:02 +03:00
Maciej Krüger
49ba06175e
Add user@address:port support
This patch allows users to specify the connection port
in the store URLS like so:

```
nix store info --store "ssh-ng://localhost:22" --json
```

Previously this failed with: `error: failed to start SSH connection to 'localhost:22'`,
because the code did not distinguish the port from the hostname. This
patch remedies that problem by introducing a ParsedURL::Authority type
for working with parsed authority components of URIs.

Now that the URL parsing code is less ad-hoc we can
add more long-awaited fixes for specifying SSH connection
ports in store URIs.

Builds upon the work from bd1d2d1041.

Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
2025-08-06 23:48:14 +03:00
Sergei Zimmerman
53492c0ecd
Merge pull request #13555 from k1gen/no-url-literals-test
Add functional test for no-url-literals experimental feature
2025-08-06 11:29:08 +03:00
Sergei Zimmerman
4333a9d5a8
ci: Collect code coverage in tests
This adds the necessary infrastructure to collect
code coverage in CI, which could be useful to look
at munually or track consistently via something like
codecov.

Co-authored-by: Jade Lovelace <lix@jade.fyi>
2025-08-04 23:50:02 +03:00
Oleksandr Knyshuk
6e8f76482e
Add functional test for no-url-literals experimental feature
Closes: #13533
2025-07-31 15:34:49 +02:00
Robert Hensing
c85a014ef9
Merge pull request #13489 from k1gen/add-warn-short-path-literals
Add warn-short-path-literals setting
2025-07-29 20:32:56 +02:00
Oleksandr Knyshuk
6d46dc9f6a
Add warn-short-path-literals setting
Add a new setting to warn about path literals that don't start with "." or "/". When enabled,
expressions like `foo/bar` will emit a warning suggesting to use `./foo/bar` instead.

A functional test is included.

The setting defaults to false for backward compatibility but could eventually default to true in
the future.

Closes: #13374

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2025-07-29 15:47:58 +02:00
Sergei Zimmerman
1c9e11a11f
tests/nixos: Parametrize on the system
All of the existing tests only run on x86_64-linux and
the whole `nixpkgsFor` makes it hard to reuse those for
e.g. running the nixos tests with a sanitizer build of nix.
This rips off the bandaid and removes the `nixpkgsFor` parameter
in favor of a single instance of nixpkgs with a separate `nixComponents`.
2025-07-29 01:24:03 +03:00
John Ericson
d21e3f88ec Implement support for Git hashing with SHA-256
SHA-256 is Git's next hash algorithm. The world is still basically stuck
on SHA-1 with git, but shouldn't be. We can at least do our part to get
ready.

On the C++ implementation side, only a little bit of generalization was
needed, and that was fairly straight-forward. The tests (unit and
system) were actually bigger, and care was taken to make sure they were
all cover both algorithms equally.
2025-07-25 10:19:08 -04:00
Eelco Dolstra
54dc5314e8 Fix nix_system_cpu on i686-linux
Fixes #13532.
2025-07-24 18:06:06 +02:00
Robert Hensing
3543a73195
Merge pull request #13456 from fzakaria/git-pack-ref-cache
Add a test case where fetchGit is failing to cache due to packed-refs
2025-07-23 23:04:29 +02:00
Farid Zakaria
aadfb682d4 Fix fetchGit functional tests to peel as well 2025-07-21 22:01:05 -07:00
Farid Zakaria
0c32b0c8c3 Added comment to test case 2025-07-22 02:52:53 +03:00
Farid Zakaria
48083028ac Add a test case for failing git cache
builtins.fetchGit is not using the cached Git directory if
packed-references are used.

This is because the ref file for the fetchGit `refs/heads/master` is
used to check the mtime for whether to cache or not.

Let's at least codify this failure in a test case.
2025-07-22 02:52:53 +03:00
OPNA2608
6db6190002 treewide: Fix Meson CPU names for powerpc CPUs 2025-07-21 19:03:49 +02:00
Graham Christensen
e4f62e4608 Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter,
* It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files
* Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose,

Let's rip the bandaid off?

Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
2025-07-18 12:47:27 -04:00
Farid Zakaria
a4f548fed1 Fix FetchGit test 2025-07-16 08:04:16 -07:00
Sergei Zimmerman
6e78cc90d3
libexpr: Fix invalid handling of errors for imported functions
c39cc00404 has added assertions for
all Value accesses and the following case has started failing with
an `unreachable`:

(/tmp/fun.nix):

```nix
{a}: a
```

```
$ nix eval --impure --expr 'import /tmp/fun.nix {a="a";b="b";}'
```

This would crash:

```
terminating due to unexpected unrecoverable internal error: Unexpected condition in getStorage at ../include/nix/expr/value.hh:844
```

This is not a regression, but rather surfaces an existing problem, which previously
was left undiagnosed. In the case of an import `fun` is the `import` primOp, so that read is invalid
and previously this resulted in an access into an inactive union member, which is UB.
The correct thing to use is `vCur`. Identical problem also affected the case of a missing argument.

Add previously failing test cases to the functional/lang test suite.

Fixes #13448.
2025-07-11 20:20:48 +03:00
tomberek
485cbfc7f1
Merge pull request #13437 from NixOS/respect-transitive-locks
lockFlake(): When updating a lock, respect the input's lock file
2025-07-10 00:28:55 -04:00
Sergei Zimmerman
b19e9acc03
Merge pull request #13402 from DavHau/build-cores
build-cores: detect cores automatically if set to 0
2025-07-09 23:06:55 +03:00
Eelco Dolstra
95437b90fc lockFlake(): When updating a lock, respect the input's lock file 2025-07-09 19:19:15 +02:00
John Soo
87299e466d installers, tests: remove --preserve=mode from cp invocations
-p preserves xattrs and acls which can be incompatible between
filesystems

Unfortunately keep -p on darwin because the bsd coreutils do not
support --preserve.

Fixes #13426
2025-07-07 15:34:18 -06:00
Thomas Bereknyei
9e7655f440 fix: make setuid tests use new build-dir location /nix/var/nix/builds 2025-07-07 10:13:40 -04:00
DavHau
fb5e22e318 build-cores: detect cores automatically if set to 0
This changes makes nix detect a machines available cores automatically whenever build-cores is set to 0.

So far, nix simply passed NIX_BUILD_CORES=0 whenever build-cores is set to 0. (only when build-cores is unset it was detecting cores automatically)

The behavior of passing NIX_BUILD_CORES=0 leads to a performance penalty when sourcing nixpkgs' generic builder's `setup.sh`, as setup.sh has to execute `nproc`. This significantly slows down sourcing of setup.sh
2025-07-07 10:33:42 +07:00
Eelco Dolstra
b415faceca Don't allow flake inputs to have both a flakeref and a follows
Having both doesn't make sense so it's best to disallow it. If this
causes issues we could turn into a warning.
2025-06-26 12:56:54 +02:00
Eelco Dolstra
637c4f3ad7 Add tests for deep overrides
Taken from https://github.com/NixOS/nix/pull/6621.

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2025-06-26 12:56:49 +02:00
Eelco Dolstra
37685b1c9c Fix Darwin test failure in repl.sh
Fixes

  error:
         … while processing sandbox path '/private/tmp/nix-shell.0MDgyx/nix-test/ca/repl/store/nix/var/nix/builds/nix-build-simple.drv-65916-3910734210' (/private/tmp/nix-shell.0MDgyx/nix-test/ca/repl/store)

         error: 'nix' is too short to be a valid store path

which happened because we were now putting the build directory
underneath the store directory.
2025-06-22 16:49:44 +02:00
Eelco Dolstra
5acf50a327 Disallow the build directory having world-writable parents 2025-06-22 16:49:44 +02:00
eldritch horrors
88b7db1ba4 libstore: Don't default build-dir to temp-dir, store setting
If a build directory is accessible to other users it is possible to
smuggle data in and out of build directories. Usually this is only
a build purity problem, but in combination with other issues it can
be used to break out of a build sandbox. to prevent this we default
to using a subdirectory of nixStateDir (which is more restrictive).

(cherry picked from pennae Lix commit 55b416f6897fb0d8a9315a530a9b7f0914458ded)
(store setting done by roberth)
2025-06-22 16:49:44 +02:00
Sergei Zimmerman
6ef683cb2a
Restore multiline formatting of lists in meson files
Applies a workaround to enforce multiline formatting
of lists to reduce code churn introduced in 93a42a5971.
2025-06-20 23:12:36 +03:00
Luc Perkins
3132aba8e4
Fix broken test 2025-06-19 15:23:10 -07:00
Luc Perkins
9c120596ec
Merge remote-tracking branch 'upstream/master' into messages-present-tense 2025-06-19 10:51:50 -07:00
John Ericson
d254c840b5
Merge pull request #13349 from obsidiansystems/structured-attrs-json
Introduce top-level `structuredAttrs` field in JSON derivation format
2025-06-18 16:35:42 -04:00
Luc Perkins
d6710b4c04
Merge remote-tracking branch 'upstream/master' into messages-present-tense 2025-06-18 08:24:23 -07:00
Luc Perkins
d2a25fbe51
Fix Nix formatting changes 2025-06-18 08:23:37 -07:00
Vladimír Čunát
77f6b6532f
tests: fixup with jq-1.8.0 2025-06-18 10:11:50 +02:00
Sergei Zimmerman
f9170a84f6
tests/functional/lang: Add sort stability test for lists langer than 16 elements
libstdc++'s std::stable_sort and new builtins.sort implementation
special-case ranges with length less than or equal to 16 and delegate
to insertionsort.

Having a larger e2e test would allow catching sort stability issues
at functional level as well.
2025-06-15 16:52:08 +00:00
Jörg Thalheim
a1fe09d2c8
Merge pull request #13350 from xokdvium/meson-format
flake: Add meson formatter
2025-06-13 11:37:32 +02:00
John Ericson
f8c1ac9515 Introduce top-level structuredAttrs field in JSON derivation format
Makes the behavoral change of #13263 without the underlying refactor.
Hopefully this clearly safe from a perf and GC perspective, and will
make it easier to benchmark #13263.
2025-06-12 20:45:47 -04:00
Pol Dellaiera
5862f38d00 docker: use callPackage, parametrise the image build 2025-06-12 19:50:31 +02:00
Luc Perkins
ab10fddc6e
Rework future tense in user-facing messages 2025-06-12 09:07:36 -07:00
Sergei Zimmerman
93a42a5971
flake: Add meson formatter
This adds a meson.format file that mostly mirrors the projects
meson style and a pre-commit hook to enforce this style.
Some low-diff files are formatted.
2025-06-11 22:08:03 +00:00
John Ericson
371fcf91c3
Merge pull request #13294 from obsidiansystems/fix-13293
Fix #13293
2025-06-11 16:55:43 -04:00
John Ericson
f42eaf2c8e Create test for #13293
It currently fails, before the fix.
2025-06-11 16:11:38 -04:00