main
1{
2 config,
3 desktop,
4 globals,
5 hostname,
6 inputs,
7 lib,
8 libx,
9 outputs,
10 stateVersion,
11 ...
12}:
13{
14
15 imports = [
16 (./. + "/${hostname}/boot.nix")
17 (./. + "/${hostname}/hardware.nix")
18
19 ./common/base
20 ./common/users
21 ]
22 ++ lib.optional (builtins.pathExists (./. + "/${hostname}/extra.nix")) ./${hostname}/extra.nix
23 ++ lib.optional (builtins.isString desktop) ./common/desktop
24 ++ lib.optional (
25 builtins.hasAttr "${hostname}" globals.machines
26 && libx.hasSyncthingFolders globals.machines."${hostname}"
27 ) ./common/services/syncthing.nix;
28
29 nixpkgs = {
30 overlays = [
31 # Our own flake exports (from overlays and pkgs dir)
32 outputs.overlays.additions
33 outputs.overlays.modifications
34 outputs.overlays.unstable-packages
35
36 # And from other flakes
37 inputs.emacs-overlay.overlay
38 outputs.overlays.emacs-31
39 inputs.chapeau-rouge.overlays.openshift
40 inputs.chick-group.overlays.default
41 inputs.go-org-readwise.overlays.default
42 inputs.radian.overlays.default
43 inputs.agenix.overlays.default
44 inputs.nix-cachyos-kernel.overlays.default
45 inputs.llm-agents.overlays.shared-nixpkgs
46
47 # Migrate to "modifications"
48 (_: prev: {
49 inherit (inputs.buildkit-tekton.packages.${prev.stdenv.hostPlatform.system}) tkn-local;
50 inherit (inputs.pass-run.packages.${prev.stdenv.hostPlatform.system}) pass-run;
51 })
52 ];
53 config = {
54 allowUnfree = true;
55 # Workaround for https://github.com/nix-community/home-manager/issues/2942
56 allowUnfreePredicate = _: true;
57 };
58 };
59
60 nix = {
61 # This will add each flake input as a registry
62 # To make nix3 commands consistent with your flake
63 registry = lib.mkForce (lib.mapAttrs (_: value: { flake = value; }) inputs);
64
65 # This will additionally add your inputs to the system's legacy channels
66 # Making legacy nix commands consistent as well, awesome!
67 nixPath = lib.mkForce (
68 lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry
69 );
70
71 optimise = {
72 automatic = true;
73 dates = [
74 "01:10"
75 "12:10"
76 ];
77 };
78
79 settings = {
80 auto-optimise-store = true;
81 experimental-features = [
82 "nix-command"
83 "flakes"
84 ];
85 sandbox = true;
86 allowed-users = [
87 "@wheel"
88 ];
89 trusted-users = [
90 "root"
91 "@wheel"
92 ];
93 # See https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-use-xdg-base-directories
94 use-xdg-base-directories = true;
95
96 # Add some "caches" (substituters)
97 substituters = [
98 "https://cache.nixos.org/"
99 "https://r-ryantm.cachix.org"
100 "https://shortbrain.cachix.org"
101 "https://vdemeester.cachix.org"
102 "https://chapeau-rouge.cachix.org"
103 "https://nixos-raspberrypi.cachix.org"
104 ];
105 trusted-public-keys = [
106 "r-ryantm.cachix.org-1:gkUbLkouDAyvBdpBX0JOdIiD2/DP1ldF3Z3Y6Gqcc4c="
107 "shortbrain.cachix.org-1:dqXcXzM0yXs3eo9ChmMfmob93eemwNyhTx7wCR4IjeQ="
108 "chapeau-rouge.cachix.org-1:r34IG766Ez4Eeanr7Zx+egzXLE2Zgvc+XRspYZPDAn8="
109 "vdemeester.cachix.org-1:eZWNOrLR9A9szeMahn9ENaoT9DB3WgOos8va+d2CU44="
110 "nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI="
111 ];
112 };
113
114 extraOptions = ''
115 connect-timeout = 5
116 download-attempts = 2
117 build-cores = 0
118 keep-outputs = true
119 keep-derivations = true
120 builders-use-substitutes = true
121 '';
122
123 # On laptops at least, make the daemon and builders low priority
124 # to have a responding system while building
125 daemonIOSchedClass = "idle";
126 daemonCPUSchedPolicy = "idle";
127 };
128
129 # `nix-daemon` will hit the stack limit when using `nixFlakes`.
130 systemd.services.nix-daemon.serviceConfig."LimitSTACK" = "infinity";
131
132 system = {
133 inherit stateVersion;
134 };
135
136}