nix.nix (3833B)
1 { config, lib, pkgs, ... }: 2 3 with lib; 4 let 5 dummyConfig = pkgs.writeText "configuration.nix" '' 6 # assert builtins.trace "This is a dummy config, use switch!" false; 7 {} 8 ''; 9 cfg = config.core.nix; 10 in 11 { 12 options = { 13 core.nix = { 14 enable = mkOption { type = types.bool; default = true; description = "Enable core.nix"; }; 15 gcDates = mkOption { 16 default = "daily"; 17 description = "Specification (in the format described by systemd.time(7)) of the time at which the garbage collector will run. "; 18 type = types.str; 19 }; 20 olderThan = mkOption { 21 default = "15d"; 22 description = "Number of day to keep when garbage collect"; 23 type = types.str; 24 }; 25 buildCores = mkOption { 26 type = types.int; 27 default = 2; 28 example = 4; 29 description = '' 30 Maximum number of concurrent tasks during one build. 31 ''; 32 }; 33 localCaches = mkOption { 34 default = [ ]; 35 description = "List of local nix caches"; 36 type = types.listOf types.str; 37 }; 38 }; 39 }; 40 config = mkIf cfg.enable { 41 environment.systemPackages = [ pkgs.git ]; 42 nix = { 43 settings = { 44 cores = cfg.buildCores; 45 substituters = cfg.localCaches ++ [ 46 "https://cache.nixos.org/" 47 "https://r-ryantm.cachix.org" 48 "https://shortbrain.cachix.org" 49 "https://vdemeester.cachix.org" 50 "https://chapeau-rouge.cachix.org" 51 ]; 52 trusted-public-keys = [ 53 "r-ryantm.cachix.org-1:gkUbLkouDAyvBdpBX0JOdIiD2/DP1ldF3Z3Y6Gqcc4c=" 54 "shortbrain.cachix.org-1:dqXcXzM0yXs3eo9ChmMfmob93eemwNyhTx7wCR4IjeQ=" 55 "mic92.cachix.org-1:gi8IhgiT3CYZnJsaW7fxznzTkMUOn1RY4GmXdT/nXYQ=" 56 "chapeau-rouge.cachix.org-1:r34IG766Ez4Eeanr7Zx+egzXLE2Zgvc+XRspYZPDAn8=" 57 "vdemeester.cachix.org-1:eZWNOrLR9A9szeMahn9ENaoT9DB3WgOos8va+d2CU44=" 58 ]; 59 }; 60 # On laptops at least, make the daemon and builders low priority 61 # to have a responding system while building 62 daemonIOSchedClass = "idle"; 63 daemonCPUSchedPolicy = "idle"; 64 # FIXME: On servers, we may change this. 65 # daemonIOSchedPriority = 5; 66 # daemonCPUSchedPolicy = "batch"; 67 68 # if hydra is down, don't wait forever 69 extraOptions = '' 70 connect-timeout = 20 71 build-cores = 0 72 keep-outputs = true 73 keep-derivations = true 74 builders-use-substitutes = true 75 experimental-features = flakes nix-command 76 ''; 77 gc = { 78 automatic = true; 79 dates = cfg.gcDates; 80 options = "--delete-older-than ${cfg.olderThan}"; 81 }; 82 nixPath = [ 83 "nixos-config=${dummyConfig}" 84 "nixpkgs=/run/current-system/nixpkgs" 85 "nixpkgs-overlays=/run/current-system/overlays/compat" 86 ]; 87 optimise = { 88 automatic = true; 89 dates = [ "01:10" "12:10" ]; 90 }; 91 nrBuildUsers = 32; 92 #nrBuildUsers = config.nix.maxJobs * 2; 93 settings = { 94 sandbox = true; 95 allowed-users = [ "@wheel" ]; 96 trusted-users = [ "root" "@wheel" ]; 97 }; 98 }; 99 100 # `nix-daemon` will hit the stack limit when using `nixFlakes`. 101 systemd.services.nix-daemon.serviceConfig."LimitSTACK" = "infinity"; 102 103 nixpkgs = { 104 overlays = [ 105 # (import ../../../nix/overlays/mkSecret.nix) 106 # (import ../../../nix/overlays/sbr.nix) 107 # (import ../../../nix/overlays/unstable.nix) 108 # (import ../../../nix).emacs 109 ]; 110 config = { 111 allowUnfree = true; 112 #allowBroken = true; 113 }; 114 }; 115 system = { 116 extraSystemBuilderCmds = '' 117 ln -sv ${pkgs.path} $out/nixpkgs 118 ln -sv ${../../../nix/overlays} $out/overlays 119 ''; 120 121 stateVersion = "22.05"; 122 }; 123 }; 124 }