blob: 4933c46ce13403fb2e5f764cad5eec2d7bcebbec [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 Greya589ea12022-10-31 00:03:57 +000025 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 Greybcb2cb72022-08-21 07:24:35 +010033
Skyler Grey6be25172022-10-30 22:58:55 +000034 flake-utils-plus.inputs.flake-utils.follows = "flake-utils";
Skyler Greybcb2cb72022-08-21 07:24:35 +010035 home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey2a7ca382022-09-01 23:15:31 +010036 home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +010037 sops-nix.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey7dfe5c62022-08-20 21:41:30 +010038 };
Skyler Grey0409e462022-08-19 23:40:48 +010039
Skyler Grey7dfe5c62022-08-20 21:41:30 +010040 outputs = inputs: let
41 inherit (inputs) self nixpkgs flake-utils;
42 in
Skyler Grey0409e462022-08-19 23:40:48 +010043 flake-utils.lib.eachDefaultSystem (system: let
Skyler Greyf649adf2022-08-26 06:47:44 +010044 pkgs = import nixpkgs {
45 inherit system;
46 overlays = import ./overlays nixpkgs.lib;
47 };
Skyler Grey7dfe5c62022-08-20 21:41:30 +010048
Skyler Greyf649adf2022-08-26 06:47:44 +010049 utils = import ./utils nixpkgs.lib;
Skyler Grey7dfe5c62022-08-20 21:41:30 +010050
51 username = "minion";
Skyler Grey2a7ca382022-09-01 23:15:31 +010052
53 isAttrType = type:
Skyler Grey1010db92022-09-05 03:21:48 +010054 if builtins.elem type.name ["submodule"]
Skyler Grey2a7ca382022-09-01 23:15:31 +010055 then true
56 else if type ? nestedTypes.elemType
57 then isAttrType type.nestedTypes.elemType
58 else false;
59
60 normalizeOptions = options:
61 if
62 nixpkgs.lib.traceSeqN 2 {
63 inherit options;
64 type = builtins.typeOf options;
65 }
66 builtins.typeOf
67 options
68 == "set"
69 then
70 nixpkgs.lib.mapAttrs (
71 name: value:
72 if
73 nixpkgs.lib.traceSeqN 3 {
74 inherit name value;
75 hasGetSubOpts = value ? getSubOptions;
76 hasType = value ? type;
77 isAttrType = value ? type && isAttrType value.type;
78 typeName = value.type.name or "unnamed";
79 type = builtins.typeOf value;
80 } (builtins.typeOf value)
81 == "set"
82 then
83 nixpkgs.lib.traceVal (normalizeOptions (
84 if value ? type && isAttrType value.type
85 then nixpkgs.lib.traceVal (value.type.getSubOptions [])
86 else nixpkgs.lib.traceVal value
87 ))
88 else value
89 )
90 options
91 else options;
Skyler Grey0409e462022-08-19 23:40:48 +010092 in {
Skyler Greybcb2cb72022-08-21 07:24:35 +010093 packages.nixosConfigurations = {
94 default = nixpkgs.lib.nixosSystem {
Skyler Grey7dfe5c62022-08-20 21:41:30 +010095 inherit system;
96
Skyler Greybcb2cb72022-08-21 07:24:35 +010097 modules = [
98 (nixpkgs.lib.pipe ./modules [
99 utils.nixFilesIn
Skyler Greybcb2cb72022-08-21 07:24:35 +0100100 (utils.interpretNonstandardModule (args:
101 args
102 // {
Skyler Greyf649adf2022-08-26 06:47:44 +0100103 home = args.config.home-manager.users.${username};
Skyler Grey2a7ca382022-09-01 23:15:31 +0100104 home-options =
105 nixpkgs.lib.traceVal (normalizeOptions
106 (args.options.home-manager.users.type.getSubOptions []));
Skyler Greyba17b652022-09-09 14:22:54 +0100107 inherit system utils;
Skyler Greybcb2cb72022-08-21 07:24:35 +0100108 }))
109 ])
Skyler Greyf649adf2022-08-26 06:47:44 +0100110 {
111 minion = import ./config.nix;
112 }
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100113 ];
114
Skyler Grey6be25172022-10-30 22:58:55 +0000115 specialArgs = inputs // {inherit inputs username;};
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100116 };
117 };
Skyler Grey0409e462022-08-19 23:40:48 +0100118 devShell = pkgs.mkShell {
119 nativeBuildInputs = with pkgs; [nodePackages.prettier alejandra];
120 buildInputs = [];
121 };
122 formatter = pkgs.alejandra;
123 });
124}