1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 05:56:03 +01:00
Commit graph

20917 commits

Author SHA1 Message Date
Eelco Dolstra
002faa3d1c Tweak error message 2025-04-01 15:17:59 +02:00
John Ericson
6a1a3fa1cb 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.

(cherry picked from commit c204e307ac)
2025-04-01 15:07:49 +02:00
Graham Christensen
f56887206f Improve and fix the error message when a file is not tracked by Git 2025-04-01 15:07:01 +02:00
mergify[bot]
cfc4db85a5
Merge pull request #12850 from Mic92/header
Revert "Create script to symlink headers to old location"
2025-04-01 12:50:04 +00:00
mergify[bot]
fadd86011f
Merge pull request #12814 from silvanshade/link-with-mold
Use mold instead of GNU ld for faster builds
2025-04-01 12:09:05 +00:00
Eelco Dolstra
b2038f120c Add test for source path display 2025-04-01 14:03:16 +02:00
Eelco Dolstra
3f0a8241fc Fix path display of empty Git repos 2025-04-01 13:58:08 +02:00
Jörg Thalheim
c69e11ac46 Revert "Create script to symlink headers to old location"
This reverts commit c6a176be62.

Polluting the source tree with untracked symlinks that can end up
dangling may be unsound.
2025-04-01 13:55:41 +02:00
Eelco Dolstra
b28bc7ae64 Make rootFS's showPath() render the paths from the original accessors
This makes paths in error messages behave similar to lazy-trees,
e.g. instead of store paths like

       error: attribute 'foobar' missing
       at /nix/store/ddzfiipzqlrh3gnprmqbadnsnrxsmc9i-source/machine/configuration.nix:209:7:
          208|
          209|       pkgs.foobar
             |       ^
          210|     ];

you now get

       error: attribute 'foobar' missing
       at /home/eelco/Misc/eelco-configurations/machine/configuration.nix:209:7:
          208|
          209|       pkgs.foobar
             |       ^
          210|     ];
2025-04-01 13:17:14 +02:00
Eelco Dolstra
5506428e67 Set path display for substituted inputs 2025-04-01 13:11:00 +02:00
Jörg Thalheim
cfeb9404a8 remove deprecated gold linker
Binutils deprecated the gold linker, so do we.
For development we now use mold instead,
we can potentially also use it for release builds later.
2025-04-01 12:52:29 +02:00
Eelco Dolstra
db70061f0b
Merge pull request #12809 from DeterminateSystems/handle-failed-cached-values
Throw CachedEvalError if a cached value exists but has type "failed"
2025-04-01 11:49:09 +02:00
Eelco Dolstra
2ec1eba7ca Merge remote-tracking branch 'origin/master' into handle-failed-cached-values 2025-04-01 11:00:27 +02:00
allrealmsoflife
d3ebbb37e8 repl: improve continuation prompt for incomplete expressions
Previously, when users entered an incomplete expression in the REPL,
the continuation prompt was just 10 blank spaces, which looked invisible
and gave the impression that the REPL had stalled.

This change updates the prompt to "         > ", aligning it visually
with 'nix-repl> ' and clearly indicating that the REPL is waiting for
more input.

Fixes: https://github.com/NixOS/nix/issues/12702
2025-04-01 10:25:40 +02:00
mergify[bot]
53e3bbdb09
Merge pull request #12844 from NixOS/mergify/bp/2.28-maintenance/pr-12805
nix-daemon: source nix-profile-daemon.sh only once (backport #12805)
2025-04-01 07:54:19 +00:00
mergify[bot]
3f5f2c4734
Merge pull request #12798 from obsidiansystems/clean-config-headers
Cleanup config headers
2025-04-01 07:47:32 +00:00
Thomas Miedema
410ea6f7cf nix-daemon: source nix-profile-daemon.sh only once
On my system (Ubuntu 24.04 with nix installed using
https://zero-to-nix.com/), I noticed that my PATH
contained multiple times the following entries:

  /home/thomas/.nix-profile/bin
  /nix/var/nix/profiles/default/bin

Fix it by inserting a missing `export`, to make
sure `nix-daemon.sh` is really only executed once.

(cherry picked from commit 2b4e3fa144)
2025-04-01 06:48:33 +00:00
Jörg Thalheim
6fe39566d2
Merge pull request #12805 from thomie/nix-daemon-source-once
nix-daemon: source nix-profile-daemon.sh only once
2025-04-01 08:46:13 +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
mergify[bot]
bf7bb0880e
Merge pull request #12837 from NixOS/mergify/bp/2.28-maintenance/pr-12817
Create script to symlink headers to old location (backport #12817)
2025-03-31 23:27:15 +00:00
John Ericson
0fe8358396 Create script to symlink headers to old location
See comments on the script; this is supposed to avoid breaking muscle
memory without complicating the build system (which proved harder than I
thought too) or not doing the header hygiene change at all.

link-headers: use pathlib consistenly and fix type errors
(cherry picked from commit c6a176be62)
2025-03-31 22:48:54 +00:00
Jörg Thalheim
0e1da295e9
Merge pull request #12817 from NixOS/link-header-script
Create script to symlink headers to old location
2025-04-01 00:48:01 +02:00
mergify[bot]
b36f6ea6f0
Merge pull request #12820 from NixOS/mergify/bp/2.28-maintenance/pr-12764
Separate headers from source files (backport #12764)
2025-03-31 22:43:56 +00:00
John Ericson
15658b259f 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.

(cherry picked from commit f3e1c47f47)
2025-03-31 18:04:04 -04:00
John Ericson
c0b219cf46 Cleanup config header for libcmd
- Since it's now private, give it a rename. Note that I want to switch the
  word order on the public ones too.

- Since it is only needed by two files, just include there rather than
  the nasty blanket-forced thing.

(cherry picked from commit 326548bae5)
2025-03-31 18:04:04 -04:00
mergify[bot]
d6359ebac5
Merge pull request #12831 from NixOS/mergify/bp/2.28-maintenance/pr-12619
rapidcheck: change to working arbitrary instances (backport #12619)
2025-03-31 21:05:33 +00:00
mergify[bot]
578022ebe5
Merge pull request #12826 from NixOS/mergify/bp/2.28-maintenance/pr-12615
flake: Enable UBSAN for checks (backport #12615)
2025-03-31 21:05:29 +00:00
mergify[bot]
b4f13afc1a
Merge pull request #12828 from NixOS/mergify/bp/2.28-maintenance/pr-12624
Improve the documentation of the store path protocol (backport #12624)
2025-03-31 20:23:05 +00:00
mergify[bot]
f7ebe64b47
Merge pull request #12829 from NixOS/mergify/bp/2.28-maintenance/pr-12730
libcmd/repl: Fix missing runNix in repl (backport #12730)
2025-03-31 20:23:01 +00:00
mergify[bot]
c7f6700d19
Merge pull request #12827 from NixOS/mergify/bp/2.28-maintenance/pr-12578
packaging: Make hydraJobs.build.* complete (backport #12578)
2025-03-31 20:22:57 +00:00
mergify[bot]
a0cfbb1a38
Merge pull request #12825 from NixOS/mergify/bp/2.28-maintenance/pr-12618
Fix minor documentation typos (backport #12618)
2025-03-31 20:22:54 +00:00
mergify[bot]
fbcef4481f
Merge pull request #12824 from NixOS/mergify/bp/2.28-maintenance/pr-12596
Advanced attributes organize (backport #12596)
2025-03-31 20:22:49 +00:00
mergify[bot]
52410685bc
Merge pull request #12822 from NixOS/mergify/bp/2.28-maintenance/pr-12773
Unexpose config headers (low hanging fruit only) (backport #12773)
2025-03-31 19:33:08 +00:00
John Ericson
c6a176be62 Create script to symlink headers to old location
See comments on the script; this is supposed to avoid breaking muscle
memory without complicating the build system (which proved harder than I
thought too) or not doing the header hygiene change at all.

link-headers: use pathlib consistenly and fix type errors
2025-03-31 21:32:27 +02:00
Brian McKenna
bbbaf4afa0 DerivedPathTest: disable prop_legacy_round_rip until fixed
(cherry picked from commit c58202c6f9)
2025-03-31 19:04:27 +00:00
Brian McKenna
02bdedbeb6 coerceToSingleDerivedPathUnchecked: pass through experimental features
This fixes a few of the property tests, now that the property tests
are actually generating arbitrary data - some of that data now
requiring experimental features to function properly.

(cherry picked from commit c82ef825d4)
2025-03-31 19:04:27 +00:00
Brian McKenna
97356e9945 rapidcheck: change to working arbitrary instances
Here we're switching to combinators instead of dereference operator.
It turns out the dereference operator was being executed upon test
setup, meaning that we were only using a only single value for each of
the executions of the property tests! Really not good.

And on Windows, we instead get:

    operator* is not allowed in this context

ff6af6fc68/src/gen/detail/GenerationHandler.cpp (L16C31-L16C71)

Now a few of the property tests fail, because we're generating cases
which haven't been exercised before.

(cherry picked from commit 9a04f1e732)
2025-03-31 19:04:26 +00:00
Sergei Zimmerman
20ce98f87b tests/functional: Add regression test for broken :sh in repl
Can't really test `:u` because it needs <nixpkgs>.

(cherry picked from commit d371aadb2b)
2025-03-31 18:40:22 +00:00
Sergei Zimmerman
49fa3e1869 libcmd/repl: Fix missing runNix in repl
Without this :u, :sh and :i repl commands fail with:

> Cannot run 'nix-shell'/`nix-env` because no method of calling the Nix
> CLI was provided. This is a configuration problem pertaining to how
> this program was built.

Remove the default ctor argument as it evidently makes catching
refactoring bugs much harder. `NixRepl` implementation lives completely
in `repl.cc`, so we can be as explicit as necessary.

(cherry picked from commit 44055dc09d)
2025-03-31 18:40:22 +00:00
Sergei Zimmerman
a5c9b10083 libcmd/repl: Make AbstractNixRepl::create respect its store argument
The only reference (according to clangd) to this function also uses `openStore`,
so this is a no-op.

(cherry picked from commit 8066e4b0c3)
2025-03-31 18:40:21 +00:00
Dmitry Bogatov
5ab3b9c616 Update doc/manual/source/protocols/store-path.md
Co-authored-by: John Ericson <git@JohnEricson.me>
(cherry picked from commit affd9bbab7)
2025-03-31 18:39:23 +00:00
Dmitry Bogatov
5805f9cb93 Improve the documentation of the store path protocol
1. Fix confusing wording that might imply unnecessary double-hashing.
2. Add references to specifics of base-32 encoding.
3. Fix incorrect description that sha256 hash of `fingerprint` is
   truncated. "Truncated" is actual wording used in Nix theses, but it has
   unusual meaning, that is better conveyed by word "compressed", which is
   used by the reference C++ implementation.
4. Clarify details of base16 encoding.

(cherry picked from commit a0facb2aba)
2025-03-31 18:39:22 +00:00
Robert Hensing
12f77a2fb9 packaging: Make hydraJobs.build.* complete
(cherry picked from commit d6139a339b)
2025-03-31 18:39:17 +00:00
Sergei Zimmerman
b50c557e74 flake: Enable UBSAN for checks
Doing this makes catching non-obvious bugs easier. GHA CI workload is
already a concern and there isn't much benefit in running the tests with
and without sanitizers at the same time, so UBSAN is enabled for default
checks.

This change doesn't affect production builds in any way, but is rather a
step in the direction of improving automated testing during development.

Relates to #10969.

(cherry picked from commit 874587516c)
2025-03-31 18:38:17 +00:00
mergify[bot]
86271c364d
Merge pull request #12821 from NixOS/mergify/bp/2.28-maintenance/pr-12759
C API / settings: remove nix-flake-c global init (backport #12759)
2025-03-31 18:37:46 +00:00
Farid Zakaria
12825ab972 Fix minor documentation typos
Was reading the store chapter and came across a few small typos
and edits.

(cherry picked from commit 33493b9ead)
2025-03-31 18:37:17 +00:00
John Ericson
3e2f4891c4 Advanced attributes organize
This is supposed to firstly improve the docs as they are, and secondly
hint at how the core conceptual information ought to be moved to the
store derivation section of the manual.

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
(cherry picked from commit 637aa0944d)
2025-03-31 18:31:12 +00:00
Robert Hensing
569631b1d5 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.

(cherry picked from commit b86a76044e)
2025-03-31 18:18:08 +00:00
Robert Hensing
5663827c7d Move call-flake.nix to nix-flake
As suggested by Ericson2314 in review
https://github.com/NixOS/nix/pull/12759#issuecomment-2755352343

(cherry picked from commit 0c75581d8b)
2025-03-31 18:17:10 +00:00
Robert Hensing
9dfadd3694 nix-expr: remove EvalSettings::addPrimOp, add const
Not required for a struct and potentially confusing.

(cherry picked from commit 6fc9651d57)
2025-03-31 18:17:09 +00:00