1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-07 17:41:00 +01:00
Commit graph

12458 commits

Author SHA1 Message Date
Cole Helbling
ef4e7df6a5
Merge detsys-main 2025-06-30 11:31:06 -07:00
Eelco Dolstra
0e352a6cec Merge remote-tracking branch 'detsys/detsys-main' into fix-deep-overrides 2025-06-25 21:53:23 +02:00
Cole Helbling
a20a7fa1ea Allow specifying args to external builder program 2025-06-24 08:25:30 -07:00
Eelco Dolstra
731b630321 Fixes for GHSA-g948-229j-48j3
Squashed commit of the following:

commit 04fff3a637d455cbb1d75937a235950e43008db9
Author: Eelco Dolstra <edolstra@gmail.com>
Date:   Thu Jun 12 12:30:32 2025 +0200

    Chown structured attr files safely

commit 5417ad445e414c649d0cfc71a05661c7bf8f3ef5
Author: Eelco Dolstra <edolstra@gmail.com>
Date:   Thu Jun 12 12:14:04 2025 +0200

    Replace 'bool sync' with an enum for clarity

    And drop writeFileAndSync().

commit 7ae0141f328d8e8e1094be24665789c05f974ba6
Author: Eelco Dolstra <edolstra@gmail.com>
Date:   Thu Jun 12 11:35:28 2025 +0200

    Drop guessOrInventPathFromFD()

    No need to do hacky stuff like that when we already know the original path.

commit 45b05098bd019da7c57cd4227a89bfd0fa65bb08
Author: Eelco Dolstra <edolstra@gmail.com>
Date:   Thu Jun 12 11:15:58 2025 +0200

    Tweak comment

commit 0af15b31209d1b7ec8addfae9a1a6b60d8f35848
Author: Raito Bezarius <raito@lix.systems>
Date:   Thu Mar 27 12:22:26 2025 +0100

    libstore: ensure that temporary directory is always 0o000 before deletion

    In the case the deletion fails, we should ensure that the temporary
    directory cannot be used for nefarious purposes.

    Change-Id: I498a2dd0999a74195d13642f44a5de1e69d46120
    Signed-off-by: Raito Bezarius <raito@lix.systems>

commit 2c20fa37b15cfa03ac6a1a6a47cdb2ed66c0827e
Author: Raito Bezarius <raito@lix.systems>
Date:   Wed Mar 26 12:42:55 2025 +0100

    libutil: ensure that `_deletePath` does NOT use absolute paths with dirfds

    When calling `_deletePath` with a parent file descriptor, `openat` is
    made effective by using relative paths to the directory file descriptor.

    To avoid the problem, the signature is changed to resist misuse with an
    assert in the prologue of the function.

    Change-Id: I6b3fc766bad2afe54dc27d47d1df3873e188de96
    Signed-off-by: Raito Bezarius <raito@lix.systems>

commit d3c370bbcae48bb825ce19fd0f73bb4eefd2c9ea
Author: Raito Bezarius <raito@lix.systems>
Date:   Wed Mar 26 01:07:47 2025 +0100

    libstore: ensure that `passAsFile` is created in the original temp dir

    This ensures that `passAsFile` data is created inside the expected
    temporary build directory by `openat()` from the parent directory file
    descriptor.

    This avoids a TOCTOU which is part of the attack chain of CVE-????.

    Change-Id: Ie5273446c4a19403088d0389ae8e3f473af8879a
    Signed-off-by: Raito Bezarius <raito@lix.systems>

commit 45d3598724f932d024ef6bc2ffb00c1bb90e6018
Author: Raito Bezarius <raito@lix.systems>
Date:   Wed Mar 26 01:06:03 2025 +0100

    libutil: writeFile variant for file descriptors

    `writeFile` lose its `sync` boolean flag to make things simpler.

    A new `writeFileAndSync` function is created and all call sites are
    converted to it.

    Change-Id: Ib871a5283a9c047db1e4fe48a241506e4aab9192
    Signed-off-by: Raito Bezarius <raito@lix.systems>

commit 732bd9b98cabf4aaf95a01fd318923de303f9996
Author: Raito Bezarius <raito@lix.systems>
Date:   Wed Mar 26 01:05:34 2025 +0100

    libstore: chown to builder variant for file descriptors

    We use it immediately for the build temporary directory.

    Change-Id: I180193c63a2b98721f5fb8e542c4e39c099bb947
    Signed-off-by: Raito Bezarius <raito@lix.systems>

commit 962c65f8dcd5570dd92c72370a862c7b38942e0d
Author: Raito Bezarius <raito@lix.systems>
Date:   Wed Mar 26 01:04:59 2025 +0100

    libstore: open build directory as a dirfd as well

    We now keep around a proper AutoCloseFD around the temporary directory
    which we plan to use for openat operations and avoiding the build
    directory being swapped out while we are doing something else.

    Change-Id: I18d387b0f123ebf2d20c6405cd47ebadc5505f2a
    Signed-off-by: Raito Bezarius <raito@lix.systems>

commit c9b42462b75b5a37ee6564c2b53cff186c8323da
Author: Raito Bezarius <raito@lix.systems>
Date:   Wed Mar 26 01:04:12 2025 +0100

    libutil: guess or invent a path from file descriptors

    This is useful for certain error recovery paths (no pun intended) that
    does not thread through the original path name.

    Change-Id: I2d800740cb4f9912e64c923120d3f977c58ccb7e
    Signed-off-by: Raito Bezarius <raito@lix.systems>
2025-06-24 09:27:39 -04:00
Eelco Dolstra
7059d2b58b Merge remote-tracking branch 'origin/2.29-maintenance' into sync-2.29.1 2025-06-23 15:02:22 +02:00
Eelco Dolstra
1d5e161755
Merge pull request #113 from DeterminateSystems/eelcodolstra/fh-851-lock-nar-hashes-by-default
Add lazy-locks setting
2025-06-19 17:01:14 +00:00
Eelco Dolstra
5842d54cee Drop bad std::move
Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
2025-06-17 08:34:34 -07:00
Eelco Dolstra
a0fb93f09b Make sandbox error messages more readable 2025-06-17 08:34:34 -07:00
Eelco Dolstra
803d461e95 Add external builders
These are helper programs that execute derivations for specified
system types (e.g. using QEMU to emulate another system type).

To use, set `external-builders`:

  external-builders = [{"systems": ["aarch64-linux"], "program": "/path/to/external-builder.py"}]

The external builder gets one command line argument, the path to a JSON file containing all necessary information about the derivation:

  {
    "args": [...],
    "builder": "/nix/store/kwcyvgdg98n98hqapaz8sw92pc2s78x6-bash-5.2p37/bin/bash",
    "env": {
      "HOME": "/homeless-shelter",
      ...
    },
    "realStoreDir": "/tmp/nix/nix/store",
    "storeDir": "/nix/store",
    "tmpDir": "/tmp/nix-shell.dzQ2hE/nix-build-patchelf-0.14.3.drv-46/build",
    "tmpDirInSandbox": "/build"
  }
2025-06-17 08:34:34 -07:00
Eelco Dolstra
95f87abf66 Cleanup 2025-06-17 08:34:34 -07:00
Eelco Dolstra
d0a263711a Remove unused variable 2025-06-17 08:34:34 -07:00
Eelco Dolstra
21fd152279 Fix macOS build 2025-06-17 08:34:34 -07:00
Eelco Dolstra
ab18d8ca5f Move cgroup support 2025-06-17 08:34:34 -07:00
Eelco Dolstra
c9bb16a741 Inline initTmpDir() 2025-06-17 08:34:34 -07:00
Eelco Dolstra
492b684b9e Get rid of tmpDirInSandbox variable 2025-06-17 08:34:34 -07:00
Eelco Dolstra
f5176500be Move autoDelChroot 2025-06-17 08:34:34 -07:00
Eelco Dolstra
5d96e55e91 Move seccomp code 2025-06-17 08:34:34 -07:00
Eelco Dolstra
1acdb9168d Move doBind() 2025-06-17 08:34:34 -07:00
Eelco Dolstra
305a9680e4 Eliminate useChroot 2025-06-17 08:34:34 -07:00
Eelco Dolstra
2d5d3e44dd Move pathsInChroot 2025-06-17 08:34:34 -07:00
Eelco Dolstra
3733f95ae5 DerivationBuilder: Move Linux/Darwin-specific code into subclasses 2025-06-17 08:22:32 -07:00
Eelco Dolstra
af1b580ff6 DerivationBuilderImpl: Drop std::optional from derivationType
No point in computing this lazily, since it's pretty much the first
thing the DerivationBuilder does.
2025-06-17 08:22:32 -07:00
Eelco Dolstra
189fdfa776 Remove duplicate comments on DerivationBuilderImpl overriden methods
Having the exact same doc comments isn't very useful/maintainable.
2025-06-17 08:22:32 -07:00
Eelco Dolstra
c6617d6f2e Remove buildUser from DerivationBuilder
The use of a `buildUser` is an implementation detail of some types of
sandboxes that shouldn't exposed.
2025-06-17 08:22:32 -07:00
Eelco Dolstra
3a4e6cadeb Improve regression testing for uncachable source paths
These now throw an error by default in the test suite.
2025-06-16 23:59:33 +02:00
Eelco Dolstra
a175c67def Fix rootFS fingerprint in the impure case 2025-06-16 23:59:33 +02:00
Eelco Dolstra
5329a45ade Git fetcher: Make dirty repos with no commits cacheable 2025-06-16 23:59:33 +02:00
Eelco Dolstra
b2905dc08e fetchToStore(): Address a FIXME 2025-06-16 12:27:44 -04:00
Eelco Dolstra
e3fa4faff9 fetchToStore(): Don't require a valid path in dry run mode 2025-06-16 12:27:44 -04:00
Eelco Dolstra
af5815fd54 Give unit tests access to a $HOME directory
Also, don't try to access cache.nixos.org in the libstore unit tests.
2025-06-16 12:27:44 -04:00
Eelco Dolstra
dc5e620032 fetchToStore() cache: Use content hashes instead of store paths
We can always compute the store path from the content hash, but not
vice versa. Storing the content hash allows `hashPath()` to be
replaced by `fetchToStore(...FetchMode::DryRun...)`, which gets us
caching in lazy-trees mode.
2025-06-16 12:27:44 -04:00
Eelco Dolstra
8b9cb382e9 Fix path field in fetcher cache
86785fd9d1 was broken because it was
storing the full path in the MountedSourceAccessor as the `path` field
in the fetcher cache key (i.e. including the
/nix/store/... prefix). Especially in the case of lazy (virtual) store
paths, this didn't work at all because those paths are different every time.
2025-06-13 22:29:20 +02:00
Eelco Dolstra
cbedb8e19a Fix broken fetchToStore() caching on unlocked inputs 2025-06-13 22:29:20 +02:00
Eelco Dolstra
b2c762cd2f
Apply suggestions from code review
Co-authored-by: Luc Perkins <lucperkins@gmail.com>
2025-06-13 21:03:58 +02:00
Eelco Dolstra
802f585406 Add lazy-locks setting
This determines whether lock file entries omit a NAR hash. They're
included by default to make lazy trees compatible with older clients.
2025-06-13 17:45:37 +02:00
Eelco Dolstra
6999183956 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-12 20:38:51 +02:00
Eelco Dolstra
a572c94333 Fix deep overrides
An override like

  inputs.foo.inputs.bar.inputs.nixpkgs.follows = "nixpkgs";

implicitly set `inputs.foo.inputs.bar` to `flake:bar`, which led to an
unexpected error like

  error: cannot find flake 'flake:bar' in the flake registries

We now no longer create a parent override (like for `foo.bar` in the
example above) if it doesn't set an explicit ref or follows
attribute. We only recursively apply its child overrides.

Fixes https://github.com/NixOS/nix/issues/8325, https://github.com/DeterminateSystems/nix-src/issues/95, https://github.com/NixOS/nix/issues/12083, https://github.com/NixOS/nix/issues/5790.
2025-06-12 20:32:58 +02:00
Luc Perkins
b8e8214d5f
Fix one more 'will' 2025-06-12 08:28:01 -07:00
Luc Perkins
e565571f69
Re-supply inadvertently deleted word 2025-06-12 08:25:10 -07:00
Eelco Dolstra
279a6b18db Formatting 2025-06-12 16:13:28 +02:00
Eelco Dolstra
6477d7c2ca mountInput(): Optimize getting the NAR hash for real store paths 2025-06-12 16:11:54 +02:00
Eelco Dolstra
fca291afc3 Fix NAR hash checking for fetchGit with lazy tees
If a NAR hash is specified, we should probably check
it. Unfortunately, for now this has the side effect of forcing NAR
hash checking of any input that has a NAR hash.
2025-06-12 16:02:42 +02:00
Eelco Dolstra
b067e6566f Git fetcher: Do not consider a null revision (i.e. workdir) to be locked 2025-06-12 16:02:42 +02:00
Cole Helbling
3114862518
Merge pull request #98 from DeterminateSystems/fix-fetchToStore-dryRun-caching
fetchToStore(): Improve caching in dry-run mode
2025-06-12 00:25:23 +00:00
Eelco Dolstra
168184a0d4
Merge pull request #100 from DeterminateSystems/lib-tests-lazy
Run nixpkgsLibTests in lazy trees mode
2025-06-11 18:51:13 +00:00
Luc Perkins
27755169f9
Merge pull request #92 from DeterminateSystems/lucperkins/fh-864-fix-error-messages-to-avoid-fake-future-tense
Fix some instances of 'will'
2025-06-11 17:27:24 +00:00
Luc Perkins
42c50aafad
Fix broken link in configuration description 2025-06-11 08:55:46 -07:00
Eelco Dolstra
31e58dcb92 nix-instantiate --eval --xml: Devirtualize the output 2025-06-11 17:18:42 +02:00
Eelco Dolstra
df7a2a1bed nix-instantiate --eval --json: Devirtualize the output 2025-06-11 17:14:33 +02:00
Eelco Dolstra
2f5a545997 fetchToStore(): Improve caching in dry-run mode
In dry-run mode, we don't need to require a valid path.
2025-06-11 16:13:40 +02:00