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

3036 commits

Author SHA1 Message Date
Sergei Zimmerman
1e5a389a2f libfetchers/git-utils: Be more correct about validating refnames
Turns out there's a much better API for this that doesn't have the
footguns of the previous method.

isLegalRefName is somewhat of a misnomer, since it's mainly used to
validate user inputs that can be either references, branch names,
psedorefs or tags.

(cherry picked from commit 5d1178b817)
2025-10-15 20:08:39 +00:00
Eelco Dolstra
2bfc564297 exportReferencesGraph: Handle heterogeneous arrays
This barfed with

   error: [json.exception.type_error.302] type must be string, but is array

on `nix build github:malt3/bazel-env#bazel-env` because it has a `exportReferencesGraph` with a value like `["string",...["string"]]`.

(cherry picked from commit 94f410b628)
2025-10-08 23:13:05 +00:00
Sergei Zimmerman
8989350d4e Revert "tests/nixos: Fix daemon store reference in authorization test"
This reverts commit 695f3bc7e3.

(cherry picked from commit 86ad8d49f9)
2025-09-17 19:59:49 +00:00
Jörg Thalheim
7c3fd50617 don't include derivation name in temporary build directories
With the migration to /nix/var/nix/builds we now have failing builds
when the derivation name is too long.
This change removes the derivation name from the temporary build to have
a predictable prefix length:

Also see: https://github.com/NixOS/infra/pull/764
for context.

(cherry picked from commit 725a2f379f)
2025-09-16 10:23:44 +00:00
Cole Helbling
3ba8b83f95 Test that using --inputs-from with a flakeref that has a dir works
Will not pass until the next commit.

(cherry picked from commit ed6ef7cdf4)
2025-09-09 18:34:36 +00:00
Cole Helbling
766a236014 Test that dir is propagated from registry entry
(cherry picked from commit 258d41bfb6)
2025-09-09 07:39:16 +00:00
Sergei Zimmerman
bbbb4ce330
libstore: Do not normalize daemon -> unix://, local -> local://
This is relied upon (specifically the `local` store) by existing
tooling [1] and we broke this in 3e7879e6df (which
was first released in 2.31).

To lessen the scope of the breakage we should not normalize "auto" references
and explicitly specified references like "local" or "daemon". It also makes
sense to canonicalize local://,daemon:// to be more compatible with prior
behavior.

[1]: 05e1b3cba2/lib/NOM/Builds.hs (L60-L64)

(cherry picked from commit 3513ab13dc)
2025-09-07 23:38:14 +03:00
Sergei Zimmerman
92066f468e 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.

(cherry picked from commit 7ed0229d1a)
2025-08-31 22:52:23 +00:00
Sergei Zimmerman
03101cc839
treewide: Bump C++ standard version to C++23
Compilers in nixpkgs have caught up and major distros
should also have recent enough compilers. It would be
nice to have newer features like more full featured
ranges and deducing this.
2025-08-19 15:33:27 +03:00
tomberek
dc2478fe79
Merge pull request #13340 from mkenigs/better-error
Improve error when can't acquire db lock
2025-08-18 15:27:58 -04:00
Sergei Zimmerman
8283a20c6a
Merge pull request #13789 from xokdvium/nix-2.3-insecure-fix
hydra: Fix otherNixes.nix_2_3
2025-08-18 21:58:35 +03:00
Sergei Zimmerman
051290b155
hydra: Fix otherNixes.nix_2_3
25.05 has it marked as insecure, but we don't care about it
for testing purposes.
2025-08-18 21:56:20 +03:00
Sergei Zimmerman
1d943f5819
flake: Apply nixfmt 1.0.0 2025-08-18 20:29:45 +03:00
Sergei Zimmerman
695f3bc7e3
tests/nixos: Fix daemon store reference in authorization test
Recent store reference cleanups have started canonicalizing
daemon -> unix://.
2025-08-16 23:31:57 +03:00
John Ericson
3e7879e6df Rewrite StoreConfig::getUri in terms of new StoreConfig::getReference
Rather than having store implementations return a free-form URI string,
have them return a `StoreReference`. This reflects that fact that this
method is supposed to invert `resolveStoreConfig`, which goes from a
`StoreReference` to some `StoreConfig` concrete derived class (based on
the registry).

`StoreConfig::getUri` is kept only as a convenience for the common case
that we want to immediately render the `StoreReference`.

A few tests were changed to use `local://` not `local`, since
`StoreReference` does not encode the `local` and `daemon` shorthands
(and instead desugars them to `local://` and `unix://` right away). I
think that is fine. `local` and `daemon` still work as input.
2025-08-13 19:06:59 -04:00
Jörg Thalheim
75740fbd75 Revert "Merge pull request #13741 from xokdvium/toml-timestamps"
This reverts commit 53ac49f72c, reversing
changes made to 8e5ca787f4.

This broke nixpkgs eval test that was depending overflowing integers...
2025-08-13 22:46:09 +02:00
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