1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 02:21:16 +02:00
Commit graph

19940 commits

Author SHA1 Message Date
Sergei Zimmerman
f3090ef703
packaging/dependencies: Use boost without enableIcu
This reduces the closure size on master by 40MiB.

```
$ nix build github:nixos/nix/1e822bd4149a8bce1da81ee2ad9404986b07914c#nix-store --out-link closure-on-master
$ nix build .#nix-store -L --out-link closure-without-icu
$ nix path-info --closure-size -h ./closure-on-master
/nix/store/8gwr38m5h6p7245ji9jv28a2a11w1isx-nix-store-2.29.0pre  124.4 MiB
$ nix path-info --closure-size -h ./closure-without-icu
/nix/store/k0gwfykjqpnmaqbwh23nk55lhanc9g24-nix-store-2.29.0pre   86.6 MiB
```
2025-05-13 08:47:24 +00:00
Sergei Zimmerman
3a1301cd6d
libstore: Use boost::regex for GC root discovery
As it turns out using `std::regex` is actually the bottleneck
for root discovery. Just substituting `std::` -> `boost::`
makes root discovery twice as fast (3x if counting only userspace time).

Some rather ad-hoc measurements to motivate the switch:

(On master)

```
nix build github:nixos/nix/1e822bd4149a8bce1da81ee2ad9404986b07914c#nix-cli --out-link result-1e822bd4149a8bce1da81ee2ad9404986b07914c
taskset -c 2,3 hyperfine "result-1e822bd4149a8bce1da81ee2ad9404986b07914c/bin/nix store gc --dry-run --max 0"
Benchmark 1: result-1e822bd4149a8bce1da81ee2ad9404986b07914c/bin/nix store gc --dry-run --max 0
  Time (mean ± σ):     481.6 ms ±   3.9 ms    [User: 336.2 ms, System: 142.0 ms]
  Range (min … max):   474.6 ms … 487.7 ms    10 runs
```

(After this patch)

```
taskset -c 2,3 hyperfine "result/bin/nix store gc --dry-run --max 0"
Benchmark 1: result/bin/nix store gc --dry-run --max 0
  Time (mean ± σ):     254.7 ms ±   9.7 ms    [User: 111.1 ms, System: 141.3 ms]
  Range (min … max):   246.5 ms … 281.3 ms    10 runs
```

`boost::regex` is a drop-in replacement for `std::regex`, but much faster.
Doing a simple before/after comparison doesn't surface any change in behavior:

```
result/bin/nix store gc --dry-run -vvvvv --max 0 |& grep "got additional" | wc -l
result-1e822bd4149a8bce1da81ee2ad9404986b07914c/bin/nix store gc --dry-run -vvvvv --max 0 |& grep "got additional" | wc -l
```
2025-05-06 21:58:52 +00:00
John Ericson
1e822bd414
Merge pull request #13141 from obsidiansystems/fix-windows-warning
Fix windows warning
2025-05-06 15:42:16 -04:00
John Ericson
1594d4b879 Fix windows warning 2025-05-06 15:02:10 -04:00
Jörg Thalheim
10358c630b
Merge pull request #13139 from NixOS/singleton-pattern
Simplify plugin registrations
2025-05-06 09:31:09 +02:00
Eelco Dolstra
060c34b664 Attempt to fix macOS build 2025-05-06 08:50:14 +02:00
Eelco Dolstra
47989a2124 Simplify ConfigRegistrations 2025-05-05 09:42:16 +02:00
Eelco Dolstra
f59ccb468e Simplify Implementations registration 2025-05-05 08:41:23 +02:00
Eelco Dolstra
93844a5998 Simplify registerInputScheme() 2025-05-05 08:35:59 +02:00
Eelco Dolstra
e7c0906521 Simplify RegisterCommand 2025-05-05 08:28:12 +02:00
Eelco Dolstra
4de7a986d4 Simplify RegisterPrimOp 2025-05-05 08:26:29 +02:00
Eelco Dolstra
b7add9736c Simplify RegisterLegacyCommand 2025-05-05 08:22:53 +02:00
Jörg Thalheim
bd80a4f176
Merge pull request #13137 from xokdvium/regex-cache-transparent
libexpr: Use C++20 heterogeneous lookup for RegexCache
2025-05-04 22:18:07 +02:00
Sergei Zimmerman
36c583dae0
libexpr: Use C++20 heterogeneous lookup for RegexCache 2025-05-04 16:03:57 +00:00
John Ericson
2676ae7ca6
Merge pull request #12676 from silvanshade/blake3-tbb
Implement memory-mapped IO and multi-threading for BLAKE3 hashing
2025-05-04 10:58:53 -04:00
Jörg Thalheim
86bf01bc84
Merge pull request #13136 from not-my-profile/fix-matrix-links
fix(docs): update Matrix channel links
2025-05-04 13:57:50 +02:00
Martin Fischer
81683a845b fix(docs): update Matrix channel links 2025-05-04 12:17:48 +02:00
Jörg Thalheim
469a6371ec
Merge pull request #13121 from tomberek/tomberek.redirect_http
fix: allow redirected HTTP uploads
2025-05-03 09:33:19 +02:00
Jörg Thalheim
7808aa2eee
Merge pull request #13129 from xokdvium/transparent-comparator
Use transparent comparators for `std::set<std::string>` (NFC)
2025-05-03 09:04:52 +02:00
Jörg Thalheim
bd643359a2
Merge pull request #13130 from xokdvium/symbol-table-chore
libexpr: Remove unused field from SymbolTable::symbols and emplace in…
2025-05-03 08:59:05 +02:00
silvanshade
7db388f597
Implement multi-threaded BLAKE3 hashing 2025-05-02 15:29:22 -06:00
silvanshade
b1783ff615
Implement memory-mapped IO for Sinks 2025-05-02 15:29:22 -06:00
silvanshade
a87c3711b6
Update flake nixpkgs 2025-05-02 15:29:22 -06:00
Sergei Zimmerman
161c5dbf39
libexpr: Remove unused field from SymbolTable::symbols and emplace into the ChunkedVector
Remove outdated and no longer relevant TODO. It's more confusing
now, since symbol table must now be addressed by uint32_t indices
in order to keep Attr size down to 16 bytes on 64 bit machines.
2025-05-02 20:42:47 +00:00
Sergei Zimmerman
ebb836d499
Use transparent comparators for std::set<std::string> (NFC)
This patch finally applies the transition to std::less<>,
which is a transparent comparator. There's no functional
change and string lookups in sets are now more efficient
and don't produce temporaries (e.g. set.find(std::string_view{"key"})).
2025-05-02 17:43:02 +00:00
Sergei Zimmerman
5278cd2396
libstore: Introduce WorkerProto::FeatureSet alias
Unfortunately Feature is just an alias to `std::string`
and not a new-type, so a ton of code relies on it being
exactly a `std::string`.

Using transparent comparators just for StringSet necessitates
using it here as well.
2025-05-02 17:40:34 +00:00
Sergei Zimmerman
55815ec225
treewide: Use PathSet alias consistently instead of std::set<Path> 2025-05-02 17:40:31 +00:00
Sergei Zimmerman
d8c97d8073
treewide: Use StringSet alias consistently instead of std::set<std::string>
The intention is to switch to transparent comparators from N3657 for
ordered set containers for strings and using the alias consistently
would simplify things.
2025-05-02 17:40:29 +00:00
Eelco Dolstra
a976a46ee8
Merge pull request #13123 from Mic92/filesystem-refactoring
Drop fs alias in favour of std::filesystem
2025-05-02 12:52:12 +02:00
Jörg Thalheim
95cf0d31df
Merge pull request #13126 from xokdvium/flex-full
libexpr: Improve lexer performance by using full scanner tables (-Cf)
2025-05-02 10:28:37 +02:00
Sergei Zimmerman
86a3fad085
libexpr: Improve lexer performance by using full scanner tables (-Cf)
This trades off some executable size for measurable lexer performance
improvements.

Note on the explicitly enabling 8bit scanner.
This is needed due to the default behavior of flex (excerpt from the manual [1]):

> Flex’s default behavior is to generate an 8-bit scanner unless you
> use the ‘-Cf’ or ‘-CF’, in which case flex defaults to generating
> 7-bit scanners unless your site was always configured to generate 8-bit
> scanners.

Some quantifyable metrics:

Nixpkgs revision: a6e3f45acf4e817532a861ab0eda4ab5485fecc1
Parsing the largest file in nixpkgs: pkgs/development/haskell-modules/hackage-packages.nix.

(Before this patch)

```
$ nix build github:nixos/nix/9fe3077d4#nix-expr
$ du --apparent-size result/lib/libnixexpr.so
2518    result/lib/libnixexpr.so
$ nix build github:nixos/nix/9fe3077d4#nix-cli
$ taskset -c 2,3 hyperfine "GC_INITIAL_HEAP_SIZE=16g \
    result/bin/nix-instantiate --parse               \
    ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix > /dev/null"
  Time (mean ± σ):     375.5 ms ±   6.3 ms    [User: 316.9 ms, System: 56.7 ms]
  Range (min … max):   368.5 ms … 388.3 ms    10 runs
```

(After the patch)

```
$ nix build .#nix-expr
$ du --apparent-size result/lib/libnixexpr.so
2685    result/lib/libnixexpr.so
$ nix build .#nix-cli
$ taskset -c 2,3 hyperfine "GC_INITIAL_HEAP_SIZE=16g \
    result/bin/nix-instantiate --parse               \
    ../nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix > /dev/null"
  Time (mean ± σ):     326.8 ms ±   4.9 ms    [User: 269.5 ms, System: 55.3 ms]
  Range (min … max):   319.7 ms … 335.5 ms    10 runs
```

Overall, the change is roughly:

- 2518KiB -> 2685KiB ~ 150 KiB of machine code
- 375ms -> 325ms ~ 50ms

The perf uplift for eval-heavy test cases is obviously less noticeable,
but it doesn't make sense not to take this free perf win.

[1]: https://westes.github.io/flex/manual/Options-Affecting-Scanner-Behavior.html#Options-Affecting-Scanner-Behavior
2025-05-01 23:10:04 +00:00
Thomas Bereknyei
90deb665eb fix: allow redirected HTTP uploads
When a PUT is redirected, some of the data can be sent by curl before headers are read. This means the subsequent PUT operation needs to seek back to origin.
2025-05-01 11:11:49 -04:00
Jörg Thalheim
9fe3077d47
Merge pull request #13014 from jfly/update-nix_fmt-man-page
Update `nix fmt` man page with official formatter example
2025-05-01 15:11:12 +02:00
Jeremy Fleischman
6f71d8a9c2 Update nix fmt man page with official formatter example
The current example relies upon [nixfmt's deprecated tree traversal
behavior](https://github.com/NixOS/nixfmt/pull/240). The simplest
alternative is the new `nixfmt-tree` wrapper for `nixfmt`/`treefmt`.
2025-05-01 14:30:43 +02:00
Jörg Thalheim
979d5a7cae Drop fs alias in favour of std::filesystem
Since we dropped fs::symlink_exists, we no longer have a need for the fs
namespace. Having less abstractions makes it easier to lookup the
functions in reference documentations.
2025-05-01 14:24:34 +02:00
Jörg Thalheim
5b59be914d Replace symlink_exists with pathExists
As it turns out the orignal implementation of symlink_exists cannot be
used in Nix because it did now std::filesystem::filesystem_error.
The new implementation fixes that but is now actually the same as
pathExists except for the path type.
2025-05-01 14:22:35 +02:00
Jörg Thalheim
143fb88ceb
Merge pull request #13122 from Mic92/directory-iterator
Replace all instances of std::filesystem::directory_iterator with DirectoryIterator
2025-05-01 14:22:21 +02:00
Jörg Thalheim
1c4496f4e5 replace all instances of std::filesystem::directory_iterator with DirectoryIterator 2025-05-01 11:54:26 +02:00
Jörg Thalheim
7ccc0d591f add DirectoryIterator to re-throw std::filesystem::filesystem_error
Co-authored-by: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com>
2025-05-01 11:54:13 +02:00
Jörg Thalheim
b5dc8181b0
Merge pull request #13107 from fricklerhandwerk/ivory-tower
docs: don't mention Haskell
2025-05-01 10:27: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
Jörg Thalheim
d5cefa625c
Merge pull request #13120 from Mic92/fix-quoting
replaceSymlink: fix quoting in error message
2025-05-01 10:25:22 +02:00
Jörg Thalheim
408746cba6 replaceSymlink: fix quoting in error message 2025-05-01 08:19:18 +02:00
mergify[bot]
4548dd1abb
Merge pull request #13112 from NaN-git/fix-json-getInteger
bugfix in getInteger(const nlohmann::json &) and add bounds checks
2025-04-30 21:20:49 +00:00
Jörg Thalheim
d155bb9012
Merge pull request #13063 from jfly/add-nix-fmt-print-command-option
Add `nix formatter build` and `nix formatter run` commands
2025-04-30 22:39:48 +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
5089f1292d
Refactor, use MixOutLinkByDefault 2025-04-29 18:40:02 -07:00
Jeremy Fleischman
7df7bde306
Refactor, extract some shared code into UnresolvedApp::build 2025-04-29 18:40:02 -07:00
Robert Hensing
e14346c7da
Refactor, dedup nix formatter attribute methods 2025-04-29 18:40:02 -07: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