blob: b68e2b15afa0903772c4a6ab1f9c0d189c22e005 [file] [log] [blame]
Skyler Grey0409e462022-08-19 23:40:48 +01001{
2 description = "Minion's NixOS configuration (since 2022-08-19)";
Skyler Greybcb2cb72022-08-21 07:24:35 +01003 inputs = {
4 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5 flake-utils.url = "github:numtide/flake-utils";
Skyler Grey2a7ca382022-09-01 23:15:31 +01006 vscode-extensions.url = "github:AmeerTaweel/nix-vscode-marketplace";
Skyler Greybcb2cb72022-08-21 07:24:35 +01007 registry = {
8 url = "github:nixos/flake-registry";
9 flake = false;
10 };
11 home-manager.url = "github:nix-community/home-manager/release-22.05";
Skyler Grey2a7ca382022-09-01 23:15:31 +010012 home-manager-unstable.url = "github:nix-community/home-manager";
Skyler Greybcb2cb72022-08-21 07:24:35 +010013 sops-nix.url = "github:Mic92/sops-nix";
14 impermanence.url = "github:nix-community/impermanence";
Skyler Grey2a7ca382022-09-01 23:15:31 +010015 gtimelog = {
16 url = "git+https://gitlab.collabora.com/collabora/gtimelog.git";
17 flake = false;
18 };
Skyler Greybcb2cb72022-08-21 07:24:35 +010019
20 home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey2a7ca382022-09-01 23:15:31 +010021 home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +010022 sops-nix.inputs.nixpkgs.follows = "nixpkgs";
23 impermanence.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey7dfe5c62022-08-20 21:41:30 +010024 };
Skyler Grey0409e462022-08-19 23:40:48 +010025
Skyler Grey7dfe5c62022-08-20 21:41:30 +010026 outputs = inputs: let
27 inherit (inputs) self nixpkgs flake-utils;
28 in
Skyler Grey0409e462022-08-19 23:40:48 +010029 flake-utils.lib.eachDefaultSystem (system: let
Skyler Greyf649adf2022-08-26 06:47:44 +010030 pkgs = import nixpkgs {
31 inherit system;
32 overlays = import ./overlays nixpkgs.lib;
33 };
Skyler Grey7dfe5c62022-08-20 21:41:30 +010034
Skyler Greyf649adf2022-08-26 06:47:44 +010035 utils = import ./utils nixpkgs.lib;
Skyler Grey7dfe5c62022-08-20 21:41:30 +010036
37 username = "minion";
Skyler Grey2a7ca382022-09-01 23:15:31 +010038
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 Grey0409e462022-08-19 23:40:48 +010078 in {
Skyler Greybcb2cb72022-08-21 07:24:35 +010079 packages.nixosConfigurations = {
80 default = nixpkgs.lib.nixosSystem {
Skyler Grey7dfe5c62022-08-20 21:41:30 +010081 inherit system;
82
Skyler Greybcb2cb72022-08-21 07:24:35 +010083 modules = [
84 (nixpkgs.lib.pipe ./modules [
85 utils.nixFilesIn
Skyler Greybcb2cb72022-08-21 07:24:35 +010086 (utils.interpretNonstandardModule (args:
87 args
88 // {
Skyler Greyf649adf2022-08-26 06:47:44 +010089 home = args.config.home-manager.users.${username};
Skyler Grey2a7ca382022-09-01 23:15:31 +010090 home-options =
91 nixpkgs.lib.traceVal (normalizeOptions
92 (args.options.home-manager.users.type.getSubOptions []));
93 inherit system;
Skyler Greybcb2cb72022-08-21 07:24:35 +010094 }))
95 ])
Skyler Greyf649adf2022-08-26 06:47:44 +010096 {
97 minion = import ./config.nix;
98 }
Skyler Grey7dfe5c62022-08-20 21:41:30 +010099 ];
100
Skyler Grey2a7ca382022-09-01 23:15:31 +0100101 specialArgs = inputs // {inherit username;};
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100102 };
103 };
Skyler Grey0409e462022-08-19 23:40:48 +0100104 devShell = pkgs.mkShell {
105 nativeBuildInputs = with pkgs; [nodePackages.prettier alejandra];
106 buildInputs = [];
107 };
108 formatter = pkgs.alejandra;
109 });
110}