aboutsummaryrefslogtreecommitdiff
path: root/modules/default.nix
blob: fbed630e12cf455a635e3f3965689326042d7bca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
lib,
flake-parts-lib,
...
}:
let
  inherit (lib) mkOption mkEnableOption types;
  inherit (flake-parts-lib) mkPerSystemOption;
in {
  # imports = [
  #   ./qmk.nix
  # ];

  options.perSystem = mkPerSystemOption ({ pkgs, system, config, ... }: {
    options.devices = mkOption {
      default = {};
      type = types.lazyAttrsOf <| types.submoduleWith {
        shorthandOnlyDefinesConfig = true;
        modules = [
          {
            _module.args = {
              inherit pkgs lib;
            };
          }
          ({ name, ... }: {
            # _module.args = {
            #   inherit pkgs lib flake-parts-lib;
            # };
            options = {
              enable = mkEnableOption name // { default = true; };
              type = mkOption {
                type = types.enum [ ];
                description = ''
                Firmware type. Extensible for other firmwares.
                '';
              };

              build = {
                flash = mkOption {
                  type = types.package;
                  description = ''
                      Flash script
                  '';
                };

              };
            };
          })

          ./qmk.nix
          ./pinecil.nix
          ./klipper.nix
        ];
      };

    };

    # config._type = "submodule";
    # };
    #   };
    # };

    config = {
      packages = config.devices |> lib.filterAttrs (_: v: v.enable) |> builtins.mapAttrs (_: v: v.build.flash);
    };
  });
}