blob: 71294fc780e6c40d2b71802ea7f90157faa80d1e [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 Grey252927a2022-10-18 22:18:15 +010040 outputs = inputs:
41 let
42 inherit (inputs) self nixpkgs flake-utils;
43 in
44 flake-utils.lib.eachDefaultSystem (system:
45 let
46 pkgs = import nixpkgs {
Skyler Grey7dfe5c62022-08-20 21:41:30 +010047 inherit system;
Skyler Grey252927a2022-10-18 22:18:15 +010048 overlays = import ./overlays nixpkgs.lib;
Skyler Grey7dfe5c62022-08-20 21:41:30 +010049 };
Skyler Grey252927a2022-10-18 22:18:15 +010050
51 utils = import ./utils nixpkgs.lib;
52
53 username = "minion";
54
55 isAttrType = type:
56 if builtins.elem type.name [ "submodule" ]
57 then true
58 else if type ? nestedTypes.elemType
59 then isAttrType type.nestedTypes.elemType
60 else false;
61
62 normalizeOptions = options:
63 if
64 nixpkgs.lib.traceSeqN 2
65 {
66 inherit options;
67 type = builtins.typeOf options;
68 }
69 builtins.typeOf
70 options
71 == "set"
72 then
73 nixpkgs.lib.mapAttrs
74 (
75 name: value:
76 if
77 nixpkgs.lib.traceSeqN 3
78 {
79 inherit name value;
80 hasGetSubOpts = value ? getSubOptions;
81 hasType = value ? type;
82 isAttrType = value ? type && isAttrType value.type;
83 typeName = value.type.name or "unnamed";
84 type = builtins.typeOf value;
85 }
86 (builtins.typeOf value)
87 == "set"
88 then
89 nixpkgs.lib.traceVal
90 (normalizeOptions (
91 if value ? type && isAttrType value.type
92 then nixpkgs.lib.traceVal (value.type.getSubOptions [ ])
93 else nixpkgs.lib.traceVal value
94 ))
95 else value
96 )
97 options
98 else options;
99 in
100 {
101 packages.nixosConfigurations = {
102 default = nixpkgs.lib.nixosSystem {
103 inherit system;
104
105 modules = [
106 (nixpkgs.lib.pipe ./modules [
107 utils.nixFilesIn
108 (utils.interpretNonstandardModule (args:
109 args
110 // {
111 home = args.config.home-manager.users.${username};
112 home-options =
113 nixpkgs.lib.traceVal (normalizeOptions
114 (args.options.home-manager.users.type.getSubOptions [ ]));
115 inherit system utils;
116 }))
117 ])
118 {
119 minion = import ./config.nix;
120 }
121 ];
122
123 specialArgs = inputs // { inherit inputs username; };
124 };
125 };
126 devShell = pkgs.mkShell {
127 nativeBuildInputs = with pkgs; [ nodePackages.prettier nixpkgs-fmt ];
128 buildInputs = [ ];
129 };
130 formatter = pkgs.nixpkgs-fmt;
131 });
Skyler Grey0409e462022-08-19 23:40:48 +0100132}