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