1# https://github.com/isabelroses/dotfiles/blob/main/modules/base/nix/nix.nix
2{lib, ...}: {
3 options = {
4 mySnippets.nix.settings = lib.mkOption {
5 type = lib.types.attrs;
6 description = "Default nix settings shared across machines.";
7
8 default = {
9 builders-use-substitutes = true;
10
11 experimental-features = [
12 "ca-derivations"
13 "fetch-closure"
14 "flakes"
15 "nix-command"
16 "recursive-nix"
17
18 # Allows Nix to automatically pick UIDs for builds, rather than creating nixbld* user accounts
19 # which is BEYOND annoying, which makes this a really nice feature to have
20 "auto-allocate-uids"
21
22 # allows Nix to execute builds inside cgroups
23 # remember you must also enable use-cgroups in the nix.conf or settings
24 "cgroups"
25
26 # enable the use of the fetchClosure built-in function in the Nix language.
27 "fetch-closure"
28 ];
29
30 substituters = [
31 "https://cache.nixos.org/"
32 ];
33
34 trusted-public-keys = [
35 ];
36
37 trusted-users = ["@admin" "@wheel" "nixbuild"];
38
39 # Free up to 20GiB whenever there is less than 5GB left.
40 # this setting is in bytes, so we multiply with 1024 by 3
41 min-free = 5 * 1024 * 1024 * 1024;
42 max-free = 20 * 1024 * 1024 * 1024;
43
44 # automatically optimise symlinks
45 # Disable auto-optimise-store because of this issue:
46 # https://github.com/NixOS/nix/issues/7273
47 # but we use lix which has a fix for this issue:
48 # https://gerrit.lix.systems/c/lix/+/2100
49 auto-optimise-store = true;
50
51 # we don't want to track the registry, but we do want to allow the usage
52 # of the `flake:` references, so we need to enable use-registries
53 use-registries = true;
54 flake-registry = "";
55
56 # let the system decide the number of max jobs
57 max-jobs = "auto";
58
59 # this defaults to true, however it slows down evaluation so maybe we should disable it
60 # some day, but we do need it for catppuccin/nix so maybe not too soon
61 allow-import-from-derivation = true;
62
63 # for direnv GC roots
64 keep-derivations = true;
65 keep-outputs = true;
66
67 # use xdg base directories for all the nix things
68 use-xdg-base-directories = true;
69 # don't warn me if the current working tree is dirty
70 # i don't need the warning because i'm working on it right now
71 warn-dirty = false;
72
73 # maximum number of parallel TCP connections used to fetch imports and binary caches, 0 means no limit
74 http-connections = 50;
75
76 # whether to accept nix configuration from a flake without prompting
77 # littrally a CVE waiting to happen <https://x.com/puckipedia/status/1693927716326703441>
78 accept-flake-config = false;
79 };
80 };
81 };
82}