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"; |
| 5 | flake-utils.url = "github:numtide/flake-utils"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 6 | vscode-extensions.url = "github:AmeerTaweel/nix-vscode-marketplace"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 7 | registry = { |
| 8 | url = "github:nixos/flake-registry"; |
| 9 | flake = false; |
| 10 | }; |
| 11 | home-manager.url = "github:nix-community/home-manager/release-22.05"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 12 | home-manager-unstable.url = "github:nix-community/home-manager"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 13 | sops-nix.url = "github:Mic92/sops-nix"; |
| 14 | impermanence.url = "github:nix-community/impermanence"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 15 | gtimelog = { |
| 16 | url = "git+https://gitlab.collabora.com/collabora/gtimelog.git"; |
| 17 | flake = false; |
| 18 | }; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 19 | |
| 20 | home-manager.inputs.nixpkgs.follows = "nixpkgs"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 21 | home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs"; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 22 | sops-nix.inputs.nixpkgs.follows = "nixpkgs"; |
| 23 | impermanence.inputs.nixpkgs.follows = "nixpkgs"; |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 24 | }; |
Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 25 | |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 26 | outputs = inputs: let |
| 27 | inherit (inputs) self nixpkgs flake-utils; |
| 28 | in |
Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 29 | flake-utils.lib.eachDefaultSystem (system: let |
Skyler Grey | f649adf | 2022-08-26 06:47:44 +0100 | [diff] [blame] | 30 | pkgs = import nixpkgs { |
| 31 | inherit system; |
| 32 | overlays = import ./overlays nixpkgs.lib; |
| 33 | }; |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 34 | |
Skyler Grey | f649adf | 2022-08-26 06:47:44 +0100 | [diff] [blame] | 35 | utils = import ./utils nixpkgs.lib; |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 36 | |
| 37 | username = "minion"; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 38 | |
| 39 | isAttrType = type: |
| 40 | if builtins.elem type.name ["submodule" ] |
| 41 | then true |
| 42 | else if type ? nestedTypes.elemType |
| 43 | then isAttrType type.nestedTypes.elemType |
| 44 | else false; |
| 45 | |
| 46 | normalizeOptions = options: |
| 47 | if |
| 48 | nixpkgs.lib.traceSeqN 2 { |
| 49 | inherit options; |
| 50 | type = builtins.typeOf options; |
| 51 | } |
| 52 | builtins.typeOf |
| 53 | options |
| 54 | == "set" |
| 55 | then |
| 56 | nixpkgs.lib.mapAttrs ( |
| 57 | name: value: |
| 58 | if |
| 59 | nixpkgs.lib.traceSeqN 3 { |
| 60 | inherit name value; |
| 61 | hasGetSubOpts = value ? getSubOptions; |
| 62 | hasType = value ? type; |
| 63 | isAttrType = value ? type && isAttrType value.type; |
| 64 | typeName = value.type.name or "unnamed"; |
| 65 | type = builtins.typeOf value; |
| 66 | } (builtins.typeOf value) |
| 67 | == "set" |
| 68 | then |
| 69 | nixpkgs.lib.traceVal (normalizeOptions ( |
| 70 | if value ? type && isAttrType value.type |
| 71 | then nixpkgs.lib.traceVal (value.type.getSubOptions []) |
| 72 | else nixpkgs.lib.traceVal value |
| 73 | )) |
| 74 | else value |
| 75 | ) |
| 76 | options |
| 77 | else options; |
Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 78 | in { |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 79 | packages.nixosConfigurations = { |
| 80 | default = nixpkgs.lib.nixosSystem { |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 81 | inherit system; |
| 82 | |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 83 | modules = [ |
| 84 | (nixpkgs.lib.pipe ./modules [ |
| 85 | utils.nixFilesIn |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 86 | (utils.interpretNonstandardModule (args: |
| 87 | args |
| 88 | // { |
Skyler Grey | f649adf | 2022-08-26 06:47:44 +0100 | [diff] [blame] | 89 | home = args.config.home-manager.users.${username}; |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 90 | home-options = |
| 91 | nixpkgs.lib.traceVal (normalizeOptions |
| 92 | (args.options.home-manager.users.type.getSubOptions [])); |
| 93 | inherit system; |
Skyler Grey | bcb2cb7 | 2022-08-21 07:24:35 +0100 | [diff] [blame] | 94 | })) |
| 95 | ]) |
Skyler Grey | f649adf | 2022-08-26 06:47:44 +0100 | [diff] [blame] | 96 | { |
| 97 | minion = import ./config.nix; |
| 98 | } |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 99 | ]; |
| 100 | |
Skyler Grey | 2a7ca38 | 2022-09-01 23:15:31 +0100 | [diff] [blame] | 101 | specialArgs = inputs // {inherit username;}; |
Skyler Grey | 7dfe5c6 | 2022-08-20 21:41:30 +0100 | [diff] [blame] | 102 | }; |
| 103 | }; |
Skyler Grey | 0409e46 | 2022-08-19 23:40:48 +0100 | [diff] [blame] | 104 | devShell = pkgs.mkShell { |
| 105 | nativeBuildInputs = with pkgs; [nodePackages.prettier alejandra]; |
| 106 | buildInputs = []; |
| 107 | }; |
| 108 | formatter = pkgs.alejandra; |
| 109 | }); |
| 110 | } |