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.default
46
47 # Migrate to "modifications"
48 (_: prev: {
49 inherit (inputs.buildkit-tekton.packages.${prev.stdenv.hostPlatform.system}) tkn-local;
50 inherit (inputs.dagger.packages.${prev.stdenv.hostPlatform.system}) dagger;
51 inherit (inputs.pass-run.packages.${prev.stdenv.hostPlatform.system}) pass-run;
52 })
53 ];
54 config = {
55 allowUnfree = true;
56 # Workaround for https://github.com/nix-community/home-manager/issues/2942
57 allowUnfreePredicate = _: true;
58 };
59 };
60
61 nix = {
62 # This will add each flake input as a registry
63 # To make nix3 commands consistent with your flake
64 registry = lib.mkForce (lib.mapAttrs (_: value: { flake = value; }) inputs);
65
66 # This will additionally add your inputs to the system's legacy channels
67 # Making legacy nix commands consistent as well, awesome!
68 nixPath = lib.mkForce (
69 lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry
70 );
71
72 optimise = {
73 automatic = true;
74 dates = [
75 "01:10"
76 "12:10"
77 ];
78 };
79
80 settings = {
81 auto-optimise-store = true;
82 experimental-features = [
83 "nix-command"
84 "flakes"
85 ];
86 sandbox = true;
87 allowed-users = [
88 "@wheel"
89 ];
90 trusted-users = [
91 "root"
92 "@wheel"
93 ];
94 # See https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-use-xdg-base-directories
95 use-xdg-base-directories = true;
96
97 # Add some "caches" (substituters)
98 substituters = [
99 "https://cache.nixos.org/"
100 "https://r-ryantm.cachix.org"
101 "https://shortbrain.cachix.org"
102 "https://vdemeester.cachix.org"
103 "https://chapeau-rouge.cachix.org"
104 "https://nixos-raspberrypi.cachix.org"
105 # Local Harmonia binary caches
106 "http://okinawa.sbr.pm:5000" # x86_64-linux
107 "http://aion.sbr.pm:5000" # aarch64-linux
108 ];
109 trusted-public-keys = [
110 "r-ryantm.cachix.org-1:gkUbLkouDAyvBdpBX0JOdIiD2/DP1ldF3Z3Y6Gqcc4c="
111 "shortbrain.cachix.org-1:dqXcXzM0yXs3eo9ChmMfmob93eemwNyhTx7wCR4IjeQ="
112 "chapeau-rouge.cachix.org-1:r34IG766Ez4Eeanr7Zx+egzXLE2Zgvc+XRspYZPDAn8="
113 "vdemeester.cachix.org-1:eZWNOrLR9A9szeMahn9ENaoT9DB3WgOos8va+d2CU44="
114 "nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI="
115 # Local Harmonia cache public keys
116 "cache.okinawa.home:gp+IG0OaO4L/J0drL8OwmDtMPmdUq4kfLwg3mR8BkCs="
117 "cache.aion.home-1:VIbchtAJWf8+T46viAsLaQYDhG9KUGVo+vWxH1Tlz94="
118 ];
119 };
120
121 extraOptions = ''
122 connect-timeout = 20
123 build-cores = 0
124 keep-outputs = true
125 keep-derivations = true
126 builders-use-substitutes = true
127 '';
128
129 # On laptops at least, make the daemon and builders low priority
130 # to have a responding system while building
131 daemonIOSchedClass = "idle";
132 daemonCPUSchedPolicy = "idle";
133 };
134
135 # `nix-daemon` will hit the stack limit when using `nixFlakes`.
136 systemd.services.nix-daemon.serviceConfig."LimitSTACK" = "infinity";
137
138 system = {
139 inherit stateVersion;
140 };
141
142}