blob: d95717544cee273e6f5ddc99661ab389e097aaa3 [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 Grey934f1422022-09-04 11:50:04 +010019 fzf-tab = {
20 url = "github:Aloxaf/fzf-tab";
21 flake = false;
22 };
Skyler Greybcb2cb72022-08-21 07:24:35 +010023
24 home-manager.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey2a7ca382022-09-01 23:15:31 +010025 home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs";
Skyler Greybcb2cb72022-08-21 07:24:35 +010026 sops-nix.inputs.nixpkgs.follows = "nixpkgs";
27 impermanence.inputs.nixpkgs.follows = "nixpkgs";
Skyler Grey7dfe5c62022-08-20 21:41:30 +010028 };
Skyler Grey0409e462022-08-19 23:40:48 +010029
Skyler Grey7dfe5c62022-08-20 21:41:30 +010030 outputs = inputs: let
31 inherit (inputs) self nixpkgs flake-utils;
32 in
Skyler Grey0409e462022-08-19 23:40:48 +010033 flake-utils.lib.eachDefaultSystem (system: let
Skyler Greyf649adf2022-08-26 06:47:44 +010034 pkgs = import nixpkgs {
35 inherit system;
36 overlays = import ./overlays nixpkgs.lib;
37 };
Skyler Grey7dfe5c62022-08-20 21:41:30 +010038
Skyler Greyf649adf2022-08-26 06:47:44 +010039 utils = import ./utils nixpkgs.lib;
Skyler Grey7dfe5c62022-08-20 21:41:30 +010040
41 username = "minion";
Skyler Grey2a7ca382022-09-01 23:15:31 +010042
43 isAttrType = type:
44 if builtins.elem type.name ["submodule" ]
45 then true
46 else if type ? nestedTypes.elemType
47 then isAttrType type.nestedTypes.elemType
48 else false;
49
50 normalizeOptions = options:
51 if
52 nixpkgs.lib.traceSeqN 2 {
53 inherit options;
54 type = builtins.typeOf options;
55 }
56 builtins.typeOf
57 options
58 == "set"
59 then
60 nixpkgs.lib.mapAttrs (
61 name: value:
62 if
63 nixpkgs.lib.traceSeqN 3 {
64 inherit name value;
65 hasGetSubOpts = value ? getSubOptions;
66 hasType = value ? type;
67 isAttrType = value ? type && isAttrType value.type;
68 typeName = value.type.name or "unnamed";
69 type = builtins.typeOf value;
70 } (builtins.typeOf value)
71 == "set"
72 then
73 nixpkgs.lib.traceVal (normalizeOptions (
74 if value ? type && isAttrType value.type
75 then nixpkgs.lib.traceVal (value.type.getSubOptions [])
76 else nixpkgs.lib.traceVal value
77 ))
78 else value
79 )
80 options
81 else options;
Skyler Grey0409e462022-08-19 23:40:48 +010082 in {
Skyler Greybcb2cb72022-08-21 07:24:35 +010083 packages.nixosConfigurations = {
84 default = nixpkgs.lib.nixosSystem {
Skyler Grey7dfe5c62022-08-20 21:41:30 +010085 inherit system;
86
Skyler Greybcb2cb72022-08-21 07:24:35 +010087 modules = [
88 (nixpkgs.lib.pipe ./modules [
89 utils.nixFilesIn
Skyler Greybcb2cb72022-08-21 07:24:35 +010090 (utils.interpretNonstandardModule (args:
91 args
92 // {
Skyler Greyf649adf2022-08-26 06:47:44 +010093 home = args.config.home-manager.users.${username};
Skyler Grey2a7ca382022-09-01 23:15:31 +010094 home-options =
95 nixpkgs.lib.traceVal (normalizeOptions
96 (args.options.home-manager.users.type.getSubOptions []));
97 inherit system;
Skyler Greybcb2cb72022-08-21 07:24:35 +010098 }))
99 ])
Skyler Greyf649adf2022-08-26 06:47:44 +0100100 {
101 minion = import ./config.nix;
102 }
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100103 ];
104
Skyler Grey2a7ca382022-09-01 23:15:31 +0100105 specialArgs = inputs // {inherit username;};
Skyler Grey7dfe5c62022-08-20 21:41:30 +0100106 };
107 };
Skyler Grey0409e462022-08-19 23:40:48 +0100108 devShell = pkgs.mkShell {
109 nativeBuildInputs = with pkgs; [nodePackages.prettier alejandra];
110 buildInputs = [];
111 };
112 formatter = pkgs.alejandra;
113 });
114}