1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00
Commit graph

2933 commits

Author SHA1 Message Date
John Ericson
d972f9e2e2 Split out store-open.hh and store-registration.hh
The existing header is a bit too big. Now the following use-cases are
separated, and get their own headers:

- Using or implementing an arbitrary store: remaining `store-api.hh`

  This is closer to just being about the `Store` (and `StoreConfig`)
  classes, as one would expect.

- Opening a store from a textual description: `store-open.hh`

  Opening an aribtrary store implementation like this requires some sort
  of store registration mechanism to exists, but the caller doesn't need
  to know how it works. This just exposes the functions which use such a
  mechanism, without exposing the mechanism itself

- Registering a store implementation: `store-registration.hh`

  This requires understanding how the mechanism actually works, and the
  mechanism in question involves templated machinery in headers we
  rather not expose to things that don't need it, as it would slow down
  compilation for no reason.
2025-05-14 16:07:57 -04:00
Eelco Dolstra
824e0d51fe Test lock file contents more precisely 2025-05-13 10:40:24 +02:00
Jörg Thalheim
ed521760bc
Merge pull request #13161 from NixOS/remove-final
nix flake prefetch: Remove __final
2025-05-13 08:50:36 +02:00
Jörg Thalheim
6fdb170fb3
Merge pull request #13159 from NixOS/ignore-dir
Avoid unnecessarily updating old lock files with 'dir' parameters
2025-05-12 22:34:50 +02:00
Eelco Dolstra
5a84237209 Improve build failure error messages
They're now laid out in a more readable way, and they shows the output
paths (if known).
2025-05-12 15:06:54 +02:00
Eelco Dolstra
da953d6d39 Add test 2025-05-09 16:55:13 +02:00
Eelco Dolstra
d00682beb2 Backward compatibility hack for dealing with dir in URL-style flakerefs 2025-05-09 10:10:42 +02:00
Jörg Thalheim
5b900120a2
Merge pull request #13117 from NixOS/file-pure-eval
Complain when using --pure-eval with --file
2025-05-01 10:26:41 +02:00
Eelco Dolstra
d46f741cdf Complain when using --pure-eval with --file
This never worked and cannot work because in pure eval mode, the
evaluator doesn't have access to the file.
2025-04-30 22:29:27 +02:00
Jeremy Fleischman
ba6b617e75
Add nix formatter build command
`nix formatter build` is sort of like `nix build`: it builds, links, and
prints a path to the formatter program:

    $ nix formatter build
    /nix/store/cb9w44vkhk2x4adfxwgdkkf5gjmm856j-treefmt/bin/treefmt

Note that unlike `nix build`, this prints the full path to the program,
not just the store path (in the example above that would be
`/nix/store/cb9w44vkhk2x4adfxwgdkkf5gjmm856j-treefmt`).

Motivation
----------

I maintain a vim plugin that automatically runs `nix fmt` on files on
save. Since `nix fmt` can be quite slow due to nix evaluation, I choose
to cache the `nix fmt `entrypoint. This was very awkward to do, see the
implementation for details:
7864607231/lua/null-ls/builtins/formatting/nix_flake_fmt.lua (L83-L110).

I recently discovered that my implementation was buggy (it didn't handle
flakes that expose a `formatter` package, such as nixpkgs), so I had to
rework the implementation:
https://github.com/nvimtools/none-ls.nvim/pull/272.

With the new `nix formatter build` command, I can delete all this akward
code, and it will be easier for other folks to build performant editor
integrations for `nix fmt`.
2025-04-29 18:40:02 -07:00
Jeremy Fleischman
5ea7b97147
refactor: create a new nix formatter run command alias for nix fmt
This refactor shouldn't change much except add a new `nix formatter run`
command. This creates space for the new `nix formatter build` command,
which I'll be introducing in the next commit.
2025-04-29 18:40:02 -07:00
Jörg Thalheim
6405d6822d tests/flakes: add regression test for resolving user flakes 2025-04-25 10:34:41 +02:00
Eelco Dolstra
68de26d38a lockFlake(): Allow registry lookups for the top-level flake
Fixes #13050.
2025-04-24 18:59:10 +02:00
Eelco Dolstra
dda265f09a Reapply "Actually ignore system/user registries during locking"
This reverts commit 3b5f0d9fb3.
2025-04-24 17:33:27 +02:00
Jörg Thalheim
3b5f0d9fb3 Revert "Actually ignore system/user registries during locking"
This reverts commit 77d4316353.
2025-04-24 11:28:11 +02:00
John Ericson
bebef8f0c4
Merge pull request #13010 from obsidiansystems/bump-nixpkgs
flake.lock: Update Nixpkgs
2025-04-20 17:59:15 -04:00
Robert Hensing
b257ea94e3 Fix pkgs.nixVersions and installTests
... by moving our stuff out of the way from upstream's
`nixComponents` and `nixDependencies` attrsets.

(I prefer not to use overlays, but let's make it work this way
first)
2025-04-20 22:20:52 +02:00
John Ericson
a0b2b75f59 Derivation "advanced attrs" test: Ensure fields are set to distinct values
We had fields set to the same values before in our test data. This is
not a problem per-se, but does mean we wouldn't catch certain mixups.
Now, the fields are set to distinct values (where possible), which makes
the test more robust.
2025-04-15 12:29:14 -04:00
Jörg Thalheim
99a16c5203
Merge pull request #13026 from roberth/issue-13018
Fix issue #13018, `sourceInfo` strict in `outputs`
2025-04-15 13:51:02 +02:00
Robert Hensing
2109a5a206 fix: Evaluate flake parent source without evaluating its outputs
This requires that we refer to the `sourceInfo` instead of the
`result`. However, `sourceInfo` does not create a chain of basedir
resolution, so we add that back with `flakeDir`.
2025-04-15 13:22:53 +02:00
John Ericson
d285b80033 Move exportReferencesGraph to DerivationOptions
Tests are updated accordingly.
2025-04-14 14:24:36 -04:00
John Ericson
307dbe9914 Test derivation options with content-addressing too
Now, both the unit and functional tests relating to derivation options
are tested both ways -- with input addressing and content-addressing
derivations.
2025-04-14 13:43:46 -04:00
John Ericson
7acc229c8f Use the same variable for content addressing in functional tests
`CONTENT_ADDRESSED` -> `NIX_TESTS_CA_BY_DEFAULT`
2025-04-14 11:20:07 -04:00
Jörg Thalheim
3f3fd2c94b
Merge pull request #12976 from picnoir/pic/multisign
store URI: introduce multiple signatures support
2025-04-14 11:20:41 +02:00
Jörg Thalheim
b1b75e1d7a tests/functional: add test for alias commands 2025-04-12 10:20:30 +02:00
Robert Hensing
fc77a89d53
Merge pull request #12699 from rvl/subflake-locking-test
tests/functional/flakes: Add test case for subflake locking
2025-04-09 19:19:34 +02:00
Eelco Dolstra
77d4316353 Actually ignore system/user registries during locking
Something went wrong in #12068 so this didn't work. Also added a test.
2025-04-09 17:59:51 +02:00
Picnoir
e12369a68e store URI: introduce multiple signatures support
Add a `secretKeyFiles` URI parameter in the store URIs receiving a
coma-separated list of Nix signing keyfiles.

For instance:

  nix copy --to "file:///tmp/store?secret-keys=/tmp/key1,/tmp/key2" \
    "$(nix build --print-out-paths nixpkgs#hello)"

The keys passed through this new store URI parameter are merged with
the key specified in the `secretKeyFile` parameter, if any.

We'd like to rotate the signing key for cache.nixos.org. To simplify
the transition, we'd like to sign the new paths with two keys: the new
one and the current one. With this, the cache can support nix
configurations only trusting the new key and legacy configurations
only trusting the current key.

See https://github.com/NixOS/rfcs/pull/149 for more informations
behind the motivation.
2025-04-09 13:30:37 +02:00
Jörg Thalheim
1de951d31d tests/functional/repl: fix race condition
the sleep 1 is not enough in some circumstances. Switching to a fifo
helps.
2025-04-07 14:00:19 +02:00
Eelco Dolstra
67e957b636 Apply makeNotAllowedError to empty repos 2025-04-02 19:57:49 +02:00
Jörg Thalheim
7a6570a11c
Merge pull request #12836 from NixOS/component-in-header-path
Expose the nix component in header include paths
2025-04-02 15:29:22 +02:00
Jörg Thalheim
c57e2486df
Merge pull request #12853 from roberth/flake-nixos-unstable
flake: nixpkgs: 24.11 -> nixos-unstable
2025-04-01 18:49:10 +02:00
John Ericson
cc24766fa6 Expose the nix component in header include paths
For example, instead of doing

    #include "nix/store-config.hh"
    #include "nix/derived-path.hh"

Now do

    #include "nix/store/config.hh"
    #include "nix/store/derived-path.hh"

This was originally planned in the issue, and also recent requested by
Eelco.

Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.

Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!

Progress on #7876
2025-04-01 11:40:42 -04:00
Robert Hensing
58b657b976 tests/nixos: Work around network-online.target inactivity 2025-04-01 16:36:47 +02:00
Robert Hensing
4de73df8bf
Merge pull request #12765 from Mic92/clan-tidy-cleanups
Add various clang tidy fixes
2025-04-01 15:36:50 +02:00
John Ericson
c204e307ac Cleanup config headers
There are two big changes:

1. Public and private config is now separated. Configuration variables
   that are only used internally do not go in a header which is
   installed.

   (Additionally, libutil has a unix-specific private config header,
   which should only be used in unix-specific code. This keeps things a
   bit more organized, in a purely private implementation-internal way.)

2. Secondly, there is no more `-include`. There are very few config
   items that need to be publically exposed, so now it is feasible to
   just make the headers that need them just including the (public)
   configuration header.

And there are also a few more small cleanups on top of those:

- The configuration files have better names.

- The few CPP variables that remain exposed in the public headers are
  now also renamed to always start with `NIX_`. This ensures they should
  not conflict with variables defined elsewhere.

- We now always use `#if` and not `#ifdef`/`#ifndef` for our
  configuration variables, which helps avoid bugs by requiring that
  variables must be defined in all cases.
2025-03-31 23:28:36 -04:00
John Ericson
f3e1c47f47 Separate headers from source files
The short answer for why we need to do this is so we can consistently do
`#include "nix/..."`. Without this change, there are ways to still make
that work, but they are hacky, and they have downsides such as making it
harder to make sure headers from the wrong Nix library (e..g.
`libnixexpr` headers in `libnixutil`) aren't being used.

The C API alraedy used `nix_api_*`, so its headers are *not* put in
subdirectories accordingly.

Progress on #7876

We resisted doing this for a while because it would be annoying to not
have the header source file pairs close by / easy to change file
path/name from one to the other. But I am ameliorating that with
symlinks in the next commit.
2025-03-31 12:20:25 -04:00
John Ericson
c36a9b8e1b
Merge pull request #12773 from roberth/config-h-low-hanging-fruit
Unexpose config headers (low hanging fruit only)
2025-03-28 12:43:28 -04:00
Robert Hensing
b86a76044e Unexpose config headers (low hanging fruit only)
- Some headers were completely redundant and have been removed.
- Other headers have been turned private.
- Unnecessary meson.build code has been removed.
- libutil-tests now has a private config header, where previously
  it had none. This removes the need to expose a package version
  macro publicly.
2025-03-28 15:17:54 +00:00
Jörg Thalheim
ca165f09c0
Merge pull request #12583 from ulucs/ulucs/skip-ifds
`nix flake show`: Skip IFDs instead of throwing
2025-03-27 11:40:49 +01:00
Jörg Thalheim
b050db951b test/ca-fd-leak: fix clang-tidy lints 2025-03-27 11:24:28 +01:00
Uluc Sengil
fcf5966488 skip ifds in nix flake show instead of throwing 2025-03-27 11:16:35 +01:00
Sergei Trofimovich
4d72e0f73b tests/functional/check-refs.nix: format newly added test 2025-03-25 06:12:19 +00:00
Sergei Trofimovich
1e7c7244cf tests/functional/check-refs.sh: guard test12 against too old nix daemon
Otherwise without the change the test fails on nix-2.26 as:

    error: derivation contains an illegal reference specifier 'dev'

Note: the error message does not match intended change.
2025-03-25 06:12:19 +00:00
Robert Hensing
f4def47c89 test illegal reference specifier error message 2025-03-25 06:12:19 +00:00
mergify[bot]
07321575ca
Merge pull request #12716 from Mic92/fix-script
tests/functional: use script flags compatible with macOS
2025-03-24 16:51:27 +00:00
Jörg Thalheim
f02c57dbfa tests/functional: use script flags compatible with macOS
Co-authored-by: John Ericson <git@JohnEricson.me>
2025-03-24 16:38:20 +01:00
Sergei Zimmerman
d371aadb2b
tests/functional: Add regression test for broken :sh in repl
Can't really test `:u` because it needs <nixpkgs>.
2025-03-23 22:13:40 +00:00
Shahar "Dawn" Or
23c7a45a05 stack overflow is EvalBaseError 2025-03-20 17:43:20 +00:00
Rodney Lorrimar
1bc82d1c86
tests/functional/flakes: Add test case for subflake locking
This adds a test case where the lockfile of a relative path flake
dependency is updated.

It was reported by a user here: https://discourse.nixos.org/t/updating-local-subflakes-inputs-when-building-root-flake/61682

I think this test case relates to issue #7730.

Because the issue is not resolved, this test case would fail without
the `|| true` clause.
2025-03-20 13:28:05 +08:00