Skip to content

Commit

Permalink
modules/nixos: change some nix.conf settings
Browse files Browse the repository at this point in the history
Reduce `connect-timeout`, `download-attempts`, and disable `preallocate-contents`. At first these may all seem like bad choices, but they have their uses. Currently, `connect-timeout` can cause Nix to hang when it fails to connect since it waits for the timeout to be reached. This isn't for just one or two things, this is for _all_ network IO that occurs from Nix, which can block on a lot of unnecessary things, such as trying to update the local narinfo db when it doesn't do anything for our invocation. `download-attempts` follows in tandem to this issue, by causing further blocks on unnecessary tasks, and as a result we want to be slightly less forgiving under low network situations.

Disabling `preallocate-contents` is actually very important because it breaks BTRFS COW functionality and compression. Furthermore, the feature itself isn't actually that important on a modern system, so doing it ahead-of-time isn't bringing any major benefits. The negatives here outweigh the non-existent positives, so it has been removed.
  • Loading branch information
Frontear committed Nov 26, 2024
1 parent d732191 commit 165479a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/nixos/programs/nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ in {

builders-use-substitutes = true;

connect-timeout = 15;
connect-timeout = 5;
cores = 2;

debugger-on-trace = true;
# debugger-on-warn = true;
download-attempts = 3;
download-attempts = 2;
eval-cache = true;

# It's useful to know when a substitute is failing!
fallback = false;

# Improve the chances of the store surviving a random crash.
fsync-metadata = true;
# fsync-store-paths = true;
# fsync-store-paths = true; TODO: on next Lix release

# Keeping these is very useful for development.
keep-build-log = true;
Expand All @@ -110,7 +110,7 @@ in {
max-jobs = "auto";
min-free = 10 * 1024 * 1024 * 1024;

preallocate-contents = true;
preallocate-contents = false; # Unnecessary on modern I/O

# Never allow a non-sandboxed build
sandbox-fallback = false;
Expand Down

0 comments on commit 165479a

Please sign in to comment.