blob: 60612f18c95f41d925111eaf98ef6a986951676d [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";
Skyler Grey2f9904e2022-09-05 03:18:02 +01005 nixpkgs-minion.url = "github:Minion3665/nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +01006 flake-utils.url = "github:numtide/flake-utils";
Skyler Grey2a7ca382022-09-01 23:15:31 +01007 vscode-extensions.url = "github:AmeerTaweel/nix-vscode-marketplace";
Skyler Greybcb2cb72022-08-21 07:24:35 +01008 registry = {
9 url = "github:nixos/flake-registry";
10 flake = false;
11 };
12 home-manager.url = "github:nix-community/home-manager/release-22.05";
Skyler Grey2a7ca382022-09-01 23:15:31 +010013 home-manager-unstable.url = "github:nix-community/home-manager";
Skyler Greybcb2cb72022-08-21 07:24:35 +010014 sops-nix.url = "github:Mic92/sops-nix";
15 impermanence.url = "github:nix-community/impermanence";
Skyler Grey2a7ca382022-09-01 23:15:31 +010016 gtimelog = {
17 url = "git+https://gitlab.collabora.com/collabora/gtimelog.git";
18 flake = false;
19 };
Skyler Grey934f1422022-09-04 11:50:04 +010020 fzf-tab = {
21 url = "github:Aloxaf/fzf-tab";
22 flake = false;
23 };
Skyler Greybcb2cb72022-08-21 07:24:35 +010024
Skyler Grey2f9904e2022-09-05 03:18:02 +010025 nixpkgs-minion.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +010026 home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey2a7ca382022-09-01 23:15:31 +010027 home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +010028 sops-nix.inputs.nixpkgs.follows = "nixpkgs";
29 impermanence.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey7dfe5c62022-08-20 21:41:30 +010030 };
Skyler Grey0409e462022-08-19 23:40:48 +010031
Skyler Grey7dfe5c62022-08-20 21:41:30 +010032 outputs = inputs: let
33 inherit (inputs) self nixpkgs flake-utils;
34 in
Skyler Grey0409e462022-08-19 23:40:48 +010035 flake-utils.lib.eachDefaultSystem (system: let
Skyler Greyf649adf2022-08-26 06:47:44 +010036 pkgs = import nixpkgs {
37 inherit system;
38 overlays = import ./overlays nixpkgs.lib;
39 };
Skyler Grey7dfe5c62022-08-20 21:41:30 +010040
Skyler Greyf649adf2022-08-26 06:47:44 +010041 utils = import ./utils nixpkgs.lib;
Skyler Grey7dfe5c62022-08-20 21:41:30 +010042
43 username = "minion";
Skyler Grey2a7ca382022-09-01 23:15:31 +010044
45 isAttrType = type:
Skyler Grey1010db92022-09-05 03:21:48 +010046 if builtins.elem type.name ["submodule"]
Skyler Grey2a7ca382022-09-01 23:15:31 +010047 then true
48 else if type ? nestedTypes.elemType
49 then isAttrType type.nestedTypes.elemType
50 else false;
51
52 normalizeOptions = options:
53 if
54 nixpkgs.lib.traceSeqN 2 {
55 inherit options;
56 type = builtins.typeOf options;
57 }
58 builtins.typeOf
59 options
60 == "set"
61 then
62 nixpkgs.lib.mapAttrs (
63 name: value:
64 if
65 nixpkgs.lib.traceSeqN 3 {
66 inherit name value;
67 hasGetSubOpts = value ? getSubOptions;
68 hasType = value ? type;
69 isAttrType = value ? type && isAttrType value.type;
70 typeName = value.type.name or "unnamed";
71 type = builtins.typeOf value;
72 } (builtins.typeOf value)
73 == "set"
74 then
75 nixpkgs.lib.traceVal (normalizeOptions (
76 if value ? type && isAttrType value.type
77 then nixpkgs.lib.traceVal (value.type.getSubOptions [])
78 else nixpkgs.lib.traceVal value
79 ))
80 else value
81 )
82 options
83 else options;
Skyler Grey0409e462022-08-19 23:40:48 +010084 in {
Skyler Greybcb2cb72022-08-21 07:24:35 +010085 packages.nixosConfigurations = {
86 default = nixpkgs.lib.nixosSystem {
Skyler Grey7dfe5c62022-08-20 21:41:30 +010087 inherit system;
88
Skyler Greybcb2cb72022-08-21 07:24:35 +010089 modules = [
90 (nixpkgs.lib.pipe ./modules [
91 utils.nixFilesIn
Skyler Greybcb2cb72022-08-21 07:24:35 +010092 (utils.interpretNonstandardModule (args:
93 args
94 // {
Skyler Greyf649adf2022-08-26 06:47:44 +010095 home = args.config.home-manager.users.${username};
Skyler Grey2a7ca382022-09-01 23:15:31 +010096 home-options =
97 nixpkgs.lib.traceVal (normalizeOptions
98 (args.options.home-manager.users.type.getSubOptions []));
99 inherit system;
Skyler Greybcb2cb72022-08-21 07:24:35 +0100100 }))
101 ])
Skyler Greyf649adf2022-08-26 06:47:44 +0100102 {
103 minion = import ./config.nix;
104 }
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100105 ];
106
Skyler Grey2a7ca382022-09-01 23:15:31 +0100107 specialArgs = inputs // {inherit username;};
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100108 };
109 };
Skyler Grey0409e462022-08-19 23:40:48 +0100110 devShell = pkgs.mkShell {
111 nativeBuildInputs = with pkgs; [nodePackages.prettier alejandra];
112 buildInputs = [];
113 };
114 formatter = pkgs.alejandra;
115 });
116}