Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 1 | { |
| 2 | description = "Minion's NixOS configuration (since 2022-08-19)"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 3 | inputs = { |
| 4 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
Skyler Grey | 2f9904e | 2022-09-05 03:18:02 +0100 | [diff] [blame] | 5 | nixpkgs-minion.url = "github:Minion3665/nixpkgs"; |
Skyler Grey | bcc6399 | 2023-01-25 21:43:55 +0000 | [diff] [blame] | 6 | nixpkgs-coc-spellchecker.url = "github:Minion3665/nixpkgs/coc-spell-checker-staging"; |
Skyler Grey | d01ca9c | 2022-11-02 08:08:32 +0000 | [diff] [blame] | 7 | nixpkgs-staging-next.url = "github:NixOS/nixpkgs/staging-next"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 8 | flake-utils.url = "github:numtide/flake-utils"; |
Skyler Grey | 6be2517 | 2022-10-30 22:58:55 +0000 | [diff] [blame] | 9 | flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 10 | vscode-extensions.url = "github:AmeerTaweel/nix-vscode-marketplace"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 11 | registry = { |
| 12 | url = "github:nixos/flake-registry"; |
| 13 | flake = false; |
| 14 | }; |
Skyler Grey | f8f0653 | 2022-11-04 10:58:38 +0000 | [diff] [blame] | 15 | home-manager.url = "github:nix-community/home-manager"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 16 | sops-nix.url = "github:Mic92/sops-nix"; |
| 17 | impermanence.url = "github:nix-community/impermanence"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 18 | gtimelog = { |
| 19 | url = "git+https://gitlab.collabora.com/collabora/gtimelog.git"; |
| 20 | flake = false; |
| 21 | }; |
Skyler Grey | 934f142 | 2022-09-04 11:50:04 +0100 | [diff] [blame] | 22 | fzf-tab = { |
| 23 | url = "github:Aloxaf/fzf-tab"; |
| 24 | flake = false; |
| 25 | }; |
Skyler Grey | a589ea1 | 2022-10-31 00:03:57 +0000 | [diff] [blame] | 26 | omnisharp-language-server = { |
| 27 | url = "github:coc-extensions/coc-omnisharp"; |
| 28 | flake = false; |
| 29 | }; |
| 30 | kmonad = { |
| 31 | url = "github:kmonad/kmonad?dir=nix"; |
| 32 | inputs.nixpkgs.follows = "nixpkgs"; |
| 33 | }; |
Skyler Grey | 6163585 | 2022-10-31 00:27:04 +0000 | [diff] [blame] | 34 | fenix.url = "github:nix-community/fenix"; |
Skyler Grey | d01ca9c | 2022-11-02 08:08:32 +0000 | [diff] [blame] | 35 | prismlauncher.url = "github:Scrumplex/nixpkgs/update-prismlauncher-5.1"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 36 | |
Skyler Grey | 6163585 | 2022-10-31 00:27:04 +0000 | [diff] [blame] | 37 | fenix.inputs.nixpkgs.follows = "nixpkgs"; |
Skyler Grey | 6be2517 | 2022-10-30 22:58:55 +0000 | [diff] [blame] | 38 | flake-utils-plus.inputs.flake-utils.follows = "flake-utils"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 39 | home-manager.inputs.nixpkgs.follows = "nixpkgs"; |
| 40 | sops-nix.inputs.nixpkgs.follows = "nixpkgs"; |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 41 | }; |
Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 42 | |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 43 | outputs = inputs: |
| 44 | let |
| 45 | inherit (inputs) self nixpkgs flake-utils; |
| 46 | in |
| 47 | flake-utils.lib.eachDefaultSystem (system: |
| 48 | let |
| 49 | pkgs = import nixpkgs { |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 50 | inherit system; |
Skyler Grey | bcc6399 | 2023-01-25 21:43:55 +0000 | [diff] [blame] | 51 | overlays = import ./overlays nixpkgs.lib (inputs // { |
| 52 | inherit inputs |
| 53 | username; |
| 54 | }); |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 55 | }; |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 56 | |
| 57 | utils = import ./utils nixpkgs.lib; |
| 58 | |
| 59 | username = "minion"; |
| 60 | |
| 61 | isAttrType = type: |
| 62 | if builtins.elem type.name [ "submodule" ] |
| 63 | then true |
| 64 | else if type ? nestedTypes.elemType |
| 65 | then isAttrType type.nestedTypes.elemType |
| 66 | else false; |
| 67 | |
| 68 | normalizeOptions = options: |
| 69 | if |
| 70 | nixpkgs.lib.traceSeqN 2 |
| 71 | { |
| 72 | inherit options; |
| 73 | type = builtins.typeOf options; |
| 74 | } |
| 75 | builtins.typeOf |
| 76 | options |
| 77 | == "set" |
| 78 | then |
| 79 | nixpkgs.lib.mapAttrs |
| 80 | ( |
| 81 | name: value: |
| 82 | if |
| 83 | nixpkgs.lib.traceSeqN 3 |
| 84 | { |
| 85 | inherit name value; |
| 86 | hasGetSubOpts = value ? getSubOptions; |
| 87 | hasType = value ? type; |
| 88 | isAttrType = value ? type && isAttrType value.type; |
| 89 | typeName = value.type.name or "unnamed"; |
| 90 | type = builtins.typeOf value; |
| 91 | } |
| 92 | (builtins.typeOf value) |
| 93 | == "set" |
| 94 | then |
| 95 | nixpkgs.lib.traceVal |
| 96 | (normalizeOptions ( |
| 97 | if value ? type && isAttrType value.type |
| 98 | then nixpkgs.lib.traceVal (value.type.getSubOptions [ ]) |
| 99 | else nixpkgs.lib.traceVal value |
| 100 | )) |
| 101 | else value |
| 102 | ) |
| 103 | options |
| 104 | else options; |
Skyler Grey | bcc6399 | 2023-01-25 21:43:55 +0000 | [diff] [blame] | 105 | |
| 106 | evalTrace = config: trace: |
| 107 | let |
| 108 | lib = nixpkgs.lib; |
| 109 | splitTrace = lib.splitString "." trace; |
| 110 | traceHead = builtins.head splitTrace; |
| 111 | traceTail = builtins.tail splitTrace; |
| 112 | resolvedTrace = |
| 113 | ( |
| 114 | if traceHead == "home" |
| 115 | then [ "home-manager" "users" username ] |
| 116 | else lib.errorIfNot (traceHead == "config") [ ] |
| 117 | ) |
| 118 | ++ traceTail; |
| 119 | in |
| 120 | ( |
| 121 | lib.pipe resolvedTrace [ |
| 122 | (lib.foldl |
| 123 | ({ value |
| 124 | , error |
| 125 | , |
| 126 | }: key: |
| 127 | if builtins.hasAttr key value |
| 128 | then { |
| 129 | value = value.${key}; |
| 130 | inherit error; |
| 131 | } |
| 132 | else { |
| 133 | value = { }; |
| 134 | error = true; |
| 135 | }) |
| 136 | { |
| 137 | value = { }; |
| 138 | error = false; |
| 139 | }) |
| 140 | (data: lib.warnIf data.error "trace@${moduleName}/${trace} is invalid; the key does not exist" data) |
| 141 | ({ value |
| 142 | , error |
| 143 | , |
| 144 | }: { |
| 145 | value = builtins.toJSON value; |
| 146 | inherit error; |
| 147 | }) |
| 148 | ({ value |
| 149 | , error |
| 150 | , |
| 151 | }: { |
| 152 | value = "trace@${moduleName}/${trace}: ${value}"; |
| 153 | inherit error; |
| 154 | }) |
| 155 | ({ value |
| 156 | , error |
| 157 | , |
| 158 | }: |
| 159 | lib.traceIf (!error) value null) |
| 160 | ] |
| 161 | ); |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 162 | in |
| 163 | { |
| 164 | packages.nixosConfigurations = { |
Skyler Grey | bcc6399 | 2023-01-25 21:43:55 +0000 | [diff] [blame] | 165 | default = nixpkgs.lib.traceValFn |
| 166 | (nixosSystem: map (evalTrace nixosSystem.config) nixosSystem.config.internal.traces) nixpkgs.lib.nixosSystem |
| 167 | { |
| 168 | inherit system; |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 169 | |
Skyler Grey | bcc6399 | 2023-01-25 21:43:55 +0000 | [diff] [blame] | 170 | modules = [ |
| 171 | (nixpkgs.lib.pipe ./modules [ |
| 172 | utils.nixFilesIn |
| 173 | (utils.interpretNonstandardModule (args: |
| 174 | args |
| 175 | // { |
| 176 | home = args.config.home-manager.users.${username}; |
| 177 | home-options = |
| 178 | nixpkgs.lib.traceVal (normalizeOptions |
| 179 | (args.options.home-manager.users.type.getSubOptions [ ])); |
| 180 | inherit system utils; |
| 181 | })) |
| 182 | ]) |
| 183 | { |
| 184 | minion = import ./config.nix; |
| 185 | } |
| 186 | ]; |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 187 | |
Skyler Grey | bcc6399 | 2023-01-25 21:43:55 +0000 | [diff] [blame] | 188 | specialArgs = inputs // { inherit inputs username; }; |
| 189 | }; |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 190 | }; |
| 191 | devShell = pkgs.mkShell { |
| 192 | nativeBuildInputs = with pkgs; [ nodePackages.prettier nixpkgs-fmt ]; |
| 193 | buildInputs = [ ]; |
| 194 | }; |
| 195 | formatter = pkgs.nixpkgs-fmt; |
| 196 | }); |
Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 197 | } |