nix.nix (3019B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | ## Nix Configuration ## {inputs, ...}: { flake.modules = { nixos.nix = { config, lib, pkgs, ... }: let inherit (lib) mkEnableOption mkIf; in { options.system.nix = { tools = mkEnableOption "Enable Additional Nix Tools"; index = mkEnableOption "Enable Package Indexer"; }; config = { nix = { # Version package = pkgs.nixFlakes; settings = { sandbox = true; auto-optimise-store = true; # User Permissions allowed-users = [ "root" "@wheel" ]; trusted-users = [ "root" "@wheel" ]; # Binary Cache inherit ((import ../../flake.nix).nixConfig) substituters trusted-substituters trusted-public-keys ; }; # Garbage Collection gc = { automatic = true; dates = "weekly"; options = "--delete-older-than 7d"; }; extraOptions = '' accept-flake-config = true warn-dirty = false experimental-features = nix-command flakes recursive-nix min-free = ${builtins.toString (1024 * 1024 * 1024)} max-free = ${builtins.toString (10 * 1024 * 1024 * 1024)} ''; ## Nix Registry ## # Registry nixPath = ["/etc/nix/inputs"]; registry = builtins.mapAttrs (_: value: {flake = value;}) ( lib.filterAttrs (_: value: value ? outputs) inputs ); }; nixpkgs.flake = { setNixPath = false; setFlakeRegistry = false; }; environment.etc = lib.mapAttrs' (name: value: { name = "nix/inputs/${name}"; value = { source = value.outPath; }; }) inputs; ## Nix Tools ## # Nix Tools nix.settings.system-features = mkIf config.system.nix.tools [ "kvm" "big-parallel" "recursive-nix" ]; environment.systemPackages = mkIf config.system.nix.tools ( with pkgs; [ cachix dix manix alejandra nix-output-monitor prettier shellcheck statix ] ); }; }; ## Package Indexer ## homeManager.nix = { lib, osConfig ? null, ... }: let enable = if osConfig != null then osConfig.system.nix.index else false; in { imports = [inputs.index.homeModules.nix-index]; home.persist.directories = [ ".cache/nix" ".cache/manix" ]; programs = { nix-index.enable = lib.mkForce enable; nix-index-database.comma.enable = lib.mkForce enable; }; }; }; } |