Commit graph

11135 commits

Author SHA1 Message Date
Jason Yundt
a5959aa121
docs: specify that flake.lock files are JSON (#11594)
* docs: specify that flake.lock files are JSON

Recently, I decided that I was going to write some code that would parse
flake.lock files. I went to the Nix Reference Manual in order to look up
information on the format of flake.lock files, and I realized that a key
detail was missing from the Nix Reference Manual: it never says that
flake.lock files are JSON files. This commit fixes that issue.

This commit makes sure to specify that flake.lock files are encoded in
UTF-8. Confusingly, there’s multiple different JSON standards. Neither
ECMA-404, 2nd Edition [1] nor ISO/IEC 21778:2017 [2] mention UTF-8. RFC
8259 requires UTF-8, but only sometimes [3]. I chose to explicitly
specify that flake.lock files are UTF-8 in order to avoid any possible
ambiguities from the JSON standards.

[1]: <https://ecma-international.org/publications-and-standards/standards/ecma-404>
[2]: <https://www.iso.org/standard/71616.html>
[3]: <https://www.rfc-editor.org/rfc/rfc8259.html#section-8.1>
2024-09-26 00:21:33 +00:00
Eelco Dolstra
062b4a489e
Merge pull request #11585 from NixOS/verify-tls
builtin:fetchurl: Enable TLS verification
2024-09-25 23:52:25 +02:00
John Ericson
2b6b03d8df Ensure error messages don't leak private key
Since #8766, invalid base64 is rendered in errors, but we don't actually
want to show this in the case of an invalid private keys.

Co-Authored-By: Eelco Dolstra <edolstra@gmail.com>
2024-09-23 16:36:48 -04:00
Eelco Dolstra
c04bc17a5a builtin:fetchurl: Enable TLS verification
This is better for privacy and to avoid leaking netrc credentials in a
MITM attack, but also the assumption that we check the hash no longer
holds in some cases (in particular for impure derivations).

Partially reverts 5db358d4d7.
2024-09-23 15:15:43 +02:00
John Ericson
d0c351bf43 Revert "base64Decode: clearer error message when an invalid character is detected"
We have a safer way of doing this.

This reverts commit dc3ccf02bf.
2024-09-20 10:41:45 -04:00
Eelco Dolstra
ec47133be3 Fix warning 2024-09-20 15:08:45 +02:00
Eelco Dolstra
088569463b Fix build without GC 2024-09-20 15:01:32 +02:00
Eelco Dolstra
b2bb92ef09 Formatting
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
2024-09-19 22:59:42 +02:00
Eelco Dolstra
2f4a7a8301 Add a few more aliases 2024-09-19 21:04:01 +02:00
Eelco Dolstra
589d8f1f2b Move GC-related definitions to eval-gc.hh 2024-09-19 21:04:01 +02:00
Eelco Dolstra
31d408c351 Alias gc_allocator 2024-09-19 21:04:01 +02:00
Eelco Dolstra
b9f78abb7f Alias traceable_allocator to std::allocator when building without GC
This allows us to get rid of a bunch of #ifdefs.
2024-09-19 21:04:01 +02:00
Eelco Dolstra
4449b0da74
Use HAVE_BOEHMGC
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-09-19 19:52:47 +02:00
Eelco Dolstra
0c2fdd2f3c Fix missing GC root in zipAttrsWith
My SNAFU was that I assumed that all the `Value *`s we put in
`attrsSeen` are already reachable (which they are), but I forgot about
the `elems` pointer in `ListBuilder`.

Fixes #11547.
2024-09-19 19:16:31 +02:00
Eelco Dolstra
9ea29ea517
Merge pull request #11540 from NixOS/meson-arm-atomic
nix-util / meson: Add -latomic on arm
2024-09-19 16:09:14 +02:00
Robert Hensing
56b8911766 nix-util / meson: Add -latomic on arm
I couldn't get the test program to work correctly after many attempts,
so let's just unblock this without making it perfect.
2024-09-19 00:01:24 +02:00
Robert Hensing
5c87c40a5e Use close_range when available
This fixes the FreeBSD build of nix-util
2024-09-18 22:42:44 +02:00
Valentin Gagarin
0f5c37c242
Merge pull request #11530 from Mic92/flake-archive 2024-09-18 20:58:06 +02:00
Jörg Thalheim
f0a4f19087 add description + example for nix flake archive
Update src/nix/flake-archive.md

Update src/nix/flake-archive.md
2024-09-18 17:31:40 +02:00
Eelco Dolstra
0ed2ab0533
Merge pull request #11527 from Mic92/macos-test-fix
Fix macOS tests with meson
2024-09-18 15:07:22 +02:00
Nikodem Rabuliński
8105307f0f Always initialize curl in parent process on darwin
Because of an objc quirk[1], calling curl_global_init for the first time
after fork() will always result in a crash.
Up until now the solution has been to set
OBJC_DISABLE_INITIALIZE_FORK_SAFETY for every nix process to ignore
that error.
This is less than ideal because we were setting it in package.nix,
which meant that running nix tests locally would fail because
that variable was not set.
Instead of working around that error we address it at the core -
by calling curl_global_init inside initLibStore, which should mean
curl will already have been initialized by the time we try to do so in
a forked process.

[1] 01edf1705f/runtime/objc-initialize.mm (L614-L636)

(cherry-picked and adapted from c7d97802e4)
2024-09-18 14:29:26 +02:00
quatquatt
9e335ee3b9 docs: Provide an example of updating multiple inputs with nix flake update
docs: Provide an example of updating multiple inputs with `nix flake update`
2024-09-17 22:50:21 -04:00
Yuriy Taraday
c7c3a7f667 Fix meson build on macOS in sandbox
Workaround at src/libstore/meson.build#L429-L434 by @Ericson2314 from
https://github.com/NixOS/nix/pull/11302 erroneously used `macos` instead
of `darwin` to distinguish macOS, while meson docs list only `darwin`:
https://mesonbuild.com/Reference-tables.html#operating-system-names.

Original thread: https://github.com/NixOS/nix/issues/2503#issuecomment-2353184049
2024-09-17 16:15:39 +02:00
John Ericson
95f2b2beab
Merge pull request #8766 from brianmcgee/fix/base64-decode-error-message
base64Decode: clearer error message when an invalid character is detected
2024-09-17 09:59:15 -04:00
Eelco Dolstra
65f138f669 nix derivation add: Remove reference to "installable"
It doesn't operate on an installable, so don't mention it.
2024-09-17 12:37:33 +02:00
Robert Hensing
799abea0c4
Merge pull request #11330 from NixOS/packfile
libgit2, GitRepo: Write (thin) packfiles
2024-09-16 14:42:59 +02:00
Robert Hensing
976f539f7d Make Repo::flush interruptible 2024-09-16 13:42:46 +02:00
Eelco Dolstra
176334d8be
Merge pull request #10612 from edolstra/no-flake-substitution
Input::fetchToStore(): Don't try to substitute
2024-09-16 12:47:50 +02:00
Eelco Dolstra
11452ce674
Merge pull request #11490 from bryanhonof/bryanhonof.add-mixenvironment-to-run
Add MixEnvironment to CmdRun
2024-09-12 20:29:16 +02:00
Robert Hensing
bbef37b4a6
Merge pull request #11423 from DeterminateSystems/ignore-stale-submodules
Git fetcher: Ignore .gitmodules entries that are not submodules
2024-09-12 18:14:18 +02:00
Bryan Honof
2226f9864e
feat(run): inherit from MixEnvironment 2024-09-12 17:47:48 +02:00
Eelco Dolstra
7aa3e7e3a5 Make the NAR parser much stricter wrt field order
We really want to enforce a canonical representation since NAR
hashing/signing/deduplication depends on that.
2024-09-12 15:57:46 +02:00
Eelco Dolstra
27ec0def74 Typo 2024-09-12 15:33:55 +02:00
Eelco Dolstra
69bf9947c7 Put 'names' in the right scope 2024-09-12 15:29:54 +02:00
Eelco Dolstra
4de9587e50 Improve badArchive() 2024-09-12 15:27:55 +02:00
Eelco Dolstra
30aa45a373 Formatting 2024-09-11 20:35:04 +02:00
John Ericson
db7c868d24
Merge pull request #11378 from Mic92/nix-dir-errors
builtins.readDir: fix nix error trace on filesystem errors
2024-09-11 13:10:28 -04:00
John Ericson
193dc49097 tweak unpack channel built-in, std::filesystem::path for tarball 2024-09-11 12:29:49 -04:00
Eelco Dolstra
1c2508f176
Merge pull request #11466 from DeterminateSystems/git-mtime-warning
Git fetcher: Don't update mtime of ref file if fetching by rev
2024-09-11 17:34:46 +02:00
Eelco Dolstra
aa41de7d82 Merge remote-tracking branch 'origin/master' into no-flake-substitution 2024-09-11 17:10:55 +02:00
Eelco Dolstra
9a7c0d8933
Merge pull request #11473 from Artturin/keepfailedreadable
Fix making the build directory kept by `keep-failed` readable
2024-09-11 14:52:50 +02:00
Eelco Dolstra
894da59186
Merge pull request #11447 from DeterminateSystems/nix-flake-metadata-chroot-store
nix flake {metadata,archive}: Fix chroot stores
2024-09-11 14:51:56 +02:00
Noam Yorav-Raphael
38bfbb297c
Use envvars NIX_CACHE_HOME, NIX_CONFIG_HOME, NIX_DATA_HOME, NIX_STATE_HOME if defined (#11351) 2024-09-11 10:36:46 +00:00
tomberek
c60e1be62c
Merge pull request #11438 from zimbatm/nix-fmt-pwd
fix(nix fmt): remove the default "." argument
2024-09-10 23:44:16 -04:00
Artturin
ebebe626ff Fix making the build directory kept by keep-failed readable
Caused by 1d3696f0fb

Without this fix the kept build directory is readable only by root

```
$ sudo ls -ld /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5
drwx------ root root 60 B Wed Sep 11 00:09:48 2024  /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5/

$ sudo ls -ld /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5/build
drwxr-xr-x nixbld1 nixbld 80 B Wed Sep 11 00:09:58 2024  /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5/build/
```
2024-09-11 00:23:14 +03:00
zimbatm
c4766d7b8b fix(nix fmt): remove the default "." argument
When `nix fmt` is called without an argument, Nix appends the "." argument before calling the formatter. The comment in the code is:
> Format the current flake out of the box

This also happens when formatting sub-folders.

This means that the formatter is now unable to distinguish, as an interface, whether the "." argument is coming from the flake or the user's intent to format the current folder. This decision should be up to the formatter.

Treefmt, for example, will automatically look up the project's root and format all the files. This is the desired behaviour. But because the "." argument is passed, it cannot function as expected.
2024-09-10 22:18:56 +02:00
Jörg Thalheim
1ca1439b1f add missing filesystem include (x86_64-darwin fix) 2024-09-10 16:45:39 +02:00
Eelco Dolstra
9c0e968843
Merge commit from fork
Fix unsafe NAR unpacking
2024-09-10 12:42:55 +02:00
Eelco Dolstra
b80b091bac Git fetcher: Don't update mtime of ref file if fetching by rev
This fixes the warning

  $ nix eval --store /tmp/nix --expr 'builtins.fetchTree { type = "git"; url = "https://github.com/DeterminateSystems/attic"; ref = "fixups-for-magic-nix-cache"; rev = "635753a2069d4b8228e846dc5c09ad361c75cd1a"; }'
  warning: could not update mtime for file '/home/eelco/.cache/nix/gitv3/09788h9zgba5lbfkaa6ija2dvi004jwsqjf5ln21i2njs07cz766/refs/heads/fixups-for-magic-nix-cache': error: changing modification time of '"/home/eelco/.cache/nix/gitv3/09788h9zgba5lbfkaa6ija2dvi004jwsqjf5ln21i2njs07cz766/refs/heads/fixups-for-magic-nix-cache"': No such file or directory

When we're fetching by rev, that file doesn't necessarily exist, and we
don't care about it anyway.
2024-09-09 19:52:21 +02:00
Eelco Dolstra
c5a4dfa660 nix flake {metadata,archive}: Fix chroot stores
Fixes

  $ nix flake metadata --store /tmp/nix nixpkgs
  error: path '/tmp/nix/nix/store/65xpqkz92d9j7k5ric4z8lzhiigxsfbg-source/flake.nix' is not in the Nix store

This has been broken since 598deb2b23.
2024-09-09 15:41:38 +02:00