blob: 52d257240e03dacccd0935f0a9c4b64253a96709 [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 Grey6be25172022-10-30 22:58:55 +00007 flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
Skyler Grey2a7ca382022-09-01 23:15:31 +01008 vscode-extensions.url = "github:AmeerTaweel/nix-vscode-marketplace";
Skyler Greybcb2cb72022-08-21 07:24:35 +01009 registry = {
10 url = "github:nixos/flake-registry";
11 flake = false;
12 };
13 home-manager.url = "github:nix-community/home-manager/release-22.05";
Skyler Grey2a7ca382022-09-01 23:15:31 +010014 home-manager-unstable.url = "github:nix-community/home-manager";
Skyler Greybcb2cb72022-08-21 07:24:35 +010015 sops-nix.url = "github:Mic92/sops-nix";
16 impermanence.url = "github:nix-community/impermanence";
Skyler Grey2a7ca382022-09-01 23:15:31 +010017 gtimelog = {
18 url = "git+https://gitlab.collabora.com/collabora/gtimelog.git";
19 flake = false;
20 };
Skyler Grey934f1422022-09-04 11:50:04 +010021 fzf-tab = {
22 url = "github:Aloxaf/fzf-tab";
23 flake = false;
24 };
Skyler Greybcb2cb72022-08-21 07:24:35 +010025
Skyler Grey2f9904e2022-09-05 03:18:02 +010026 nixpkgs-minion.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey6be25172022-10-30 22:58:55 +000027 flake-utils-plus.inputs.flake-utils.follows = "flake-utils";
Skyler Greybcb2cb72022-08-21 07:24:35 +010028 home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey2a7ca382022-09-01 23:15:31 +010029 home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +010030 sops-nix.inputs.nixpkgs.follows = "nixpkgs";
31 impermanence.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey7dfe5c62022-08-20 21:41:30 +010032 };
Skyler Grey0409e462022-08-19 23:40:48 +010033
Skyler Grey7dfe5c62022-08-20 21:41:30 +010034 outputs = inputs: let
35 inherit (inputs) self nixpkgs flake-utils;
36 in
Skyler Grey0409e462022-08-19 23:40:48 +010037 flake-utils.lib.eachDefaultSystem (system: let
Skyler Greyf649adf2022-08-26 06:47:44 +010038 pkgs = import nixpkgs {
39 inherit system;
40 overlays = import ./overlays nixpkgs.lib;
41 };
Skyler Grey7dfe5c62022-08-20 21:41:30 +010042
Skyler Greyf649adf2022-08-26 06:47:44 +010043 utils = import ./utils nixpkgs.lib;
Skyler Grey7dfe5c62022-08-20 21:41:30 +010044
45 username = "minion";
Skyler Grey2a7ca382022-09-01 23:15:31 +010046
47 isAttrType = type:
Skyler Grey1010db92022-09-05 03:21:48 +010048 if builtins.elem type.name ["submodule"]
Skyler Grey2a7ca382022-09-01 23:15:31 +010049 then true
50 else if type ? nestedTypes.elemType
51 then isAttrType type.nestedTypes.elemType
52 else false;
53
54 normalizeOptions = options:
55 if
56 nixpkgs.lib.traceSeqN 2 {
57 inherit options;
58 type = builtins.typeOf options;
59 }
60 builtins.typeOf
61 options
62 == "set"
63 then
64 nixpkgs.lib.mapAttrs (
65 name: value:
66 if
67 nixpkgs.lib.traceSeqN 3 {
68 inherit name value;
69 hasGetSubOpts = value ? getSubOptions;
70 hasType = value ? type;
71 isAttrType = value ? type && isAttrType value.type;
72 typeName = value.type.name or "unnamed";
73 type = builtins.typeOf value;
74 } (builtins.typeOf value)
75 == "set"
76 then
77 nixpkgs.lib.traceVal (normalizeOptions (
78 if value ? type && isAttrType value.type
79 then nixpkgs.lib.traceVal (value.type.getSubOptions [])
80 else nixpkgs.lib.traceVal value
81 ))
82 else value
83 )
84 options
85 else options;
Skyler Grey0409e462022-08-19 23:40:48 +010086 in {
Skyler Greybcb2cb72022-08-21 07:24:35 +010087 packages.nixosConfigurations = {
88 default = nixpkgs.lib.nixosSystem {
Skyler Grey7dfe5c62022-08-20 21:41:30 +010089 inherit system;
90
Skyler Greybcb2cb72022-08-21 07:24:35 +010091 modules = [
92 (nixpkgs.lib.pipe ./modules [
93 utils.nixFilesIn
Skyler Greybcb2cb72022-08-21 07:24:35 +010094 (utils.interpretNonstandardModule (args:
95 args
96 // {
Skyler Greyf649adf2022-08-26 06:47:44 +010097 home = args.config.home-manager.users.${username};
Skyler Grey2a7ca382022-09-01 23:15:31 +010098 home-options =
99 nixpkgs.lib.traceVal (normalizeOptions
100 (args.options.home-manager.users.type.getSubOptions []));
Skyler Greyba17b652022-09-09 14:22:54 +0100101 inherit system utils;
Skyler Greybcb2cb72022-08-21 07:24:35 +0100102 }))
103 ])
Skyler Greyf649adf2022-08-26 06:47:44 +0100104 {
105 minion = import ./config.nix;
106 }
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100107 ];
108
Skyler Grey6be25172022-10-30 22:58:55 +0000109 specialArgs = inputs // {inherit inputs username;};
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100110 };
111 };
Skyler Grey0409e462022-08-19 23:40:48 +0100112 devShell = pkgs.mkShell {
113 nativeBuildInputs = with pkgs; [nodePackages.prettier alejandra];
114 buildInputs = [];
115 };
116 formatter = pkgs.alejandra;
117 });
118}