main
1{
2 config,
3 hostname,
4 inputs,
5 lib,
6 outputs,
7 ...
8}:
9{
10 imports = [
11 (./. + "/${hostname}/system.nix")
12
13 # ./common/base
14 ];
15
16 nixpkgs = {
17 # NOTE: Overlays might cause infinite recursion in system-manager
18 # Only apply them for NixOS systems
19 overlays = lib.optionals (!(config.system-manager.allowAnyDistro or false)) [
20 # Our own flake exports (from overlays and pkgs dir)
21 outputs.overlays.additions
22 outputs.overlays.modifications
23 outputs.overlays.unstable-packages
24
25 # And from other flakes
26 inputs.emacs-overlay.overlay
27 inputs.chapeau-rouge.overlays.openshift
28 inputs.chick-group.overlays.default
29 inputs.agenix.overlays.default
30
31 # Migrate to "modifications"
32 (_: prev: {
33 inherit (inputs.buildkit-tekton.packages.${prev.stdenv.hostPlatform.system}) tkn-local;
34 })
35 ];
36 config = {
37 allowUnfree = true;
38 };
39 };
40 nix =
41 lib.optionalAttrs (!(config.system-manager.allowAnyDistro or false)) {
42 # This will add each flake input as a registry
43 # To make nix3 commands consistent with your flake
44 # NOTE: These options only exist in NixOS, not in system-manager
45 registry = lib.mkForce (lib.mapAttrs (_: value: { flake = value; }) inputs);
46
47 # This will additionally add your inputs to the system's legacy channels
48 # Making legacy nix commands consistent as well, awesome!
49 nixPath = lib.mkForce (
50 lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry
51 );
52 }
53 // lib.optionalAttrs (!(config.system-manager.allowAnyDistro or false)) {
54 # NOTE: optimise only exists in NixOS, not in system-manager
55 optimise = {
56 automatic = true;
57 dates = [
58 "01:10"
59 "12:10"
60 ];
61 };
62 }
63 // {
64
65 settings = {
66 auto-optimise-store = true;
67 experimental-features = [
68 "nix-command"
69 "flakes"
70 ];
71 sandbox = true;
72 allowed-users = [
73 "@wheel"
74 ];
75 trusted-users = [
76 "root"
77 "@wheel"
78 ];
79 # See https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-use-xdg-base-directories
80 use-xdg-base-directories = true;
81
82 # Add some "caches" (substituters)
83 substituters = [
84 "https://cache.nixos.org/"
85 "https://r-ryantm.cachix.org"
86 "https://shortbrain.cachix.org"
87 "https://vdemeester.cachix.org"
88 "https://chapeau-rouge.cachix.org"
89 ];
90 trusted-public-keys = [
91 "r-ryantm.cachix.org-1:gkUbLkouDAyvBdpBX0JOdIiD2/DP1ldF3Z3Y6Gqcc4c="
92 "shortbrain.cachix.org-1:dqXcXzM0yXs3eo9ChmMfmob93eemwNyhTx7wCR4IjeQ="
93 "mic92.cachix.org-1:gi8IhgiT3CYZnJsaW7fxznzTkMUOn1RY4GmXdT/nXYQ="
94 "chapeau-rouge.cachix.org-1:r34IG766Ez4Eeanr7Zx+egzXLE2Zgvc+XRspYZPDAn8="
95 "vdemeester.cachix.org-1:eZWNOrLR9A9szeMahn9ENaoT9DB3WgOos8va+d2CU44="
96 ];
97 };
98
99 extraOptions = ''
100 connect-timeout = 20
101 build-cores = 0
102 keep-outputs = true
103 keep-derivations = true
104 builders-use-substitutes = true
105 '';
106 }
107 // lib.optionalAttrs (!(config.system-manager.allowAnyDistro or false)) {
108 # On laptops at least, make the daemon and builders low priority
109 # to have a responding system while building
110 # NOTE: These options only exist in NixOS, not in system-manager
111 daemonIOSchedClass = "idle";
112 daemonCPUSchedPolicy = "idle";
113 };
114}