summaryrefslogtreecommitdiff
path: root/lib/helper.nix
blob: def0ac747e5e5ecb3414199422184a3a71b5aefb (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
68
69
70
71
72
73
74
75
76
77
78
79
80
{inputs}: let
  helper = (import ./helper.nix) {inherit inputs;};
in rec {
  # Library to shorten flake.

  # Package Helpers
  pkgsFor = sys: inputs.nixpkgs.legacyPackages.${sys};

  # Miscellaneous
  forAllSystems = inputs.nixpkgs.lib.genAttrs [
    "aarch64-linux"
    "x86_64-linux"
    "aarch64-darwin"
    "x86_64-darwin"
  ];

  # Create a custom packages overlat for use in configs. IDK HOW THIS WORKS BUT IT DOES
  customPackagesOverlay.nixpkgs.overlays = [
    (final: prev:
      import ../pkgs {
        pkgs = final;
        inherit inputs;
      })
  ];

  # Create custom packages set for exposure via flake.
  customPackages = forAllSystems (
    system:
      import ../pkgs {
        pkgs = inputs.nixpkgs.legacyPackages.${system};
        inherit inputs;
      }
  );

  # Get Custom Libraries
  umport = (import ./umport.nix {inherit (inputs.nixpkgs) lib;}).umport;

  # Configuration Buildables
  mkNixosSystem = system: architecture: (
    inputs.nixpkgs.lib.nixosSystem {
      specialArgs = {
        inherit inputs helper;
      };
      modules =
        [
          ../nixos/systems/${system}/system.nix
          ../nixos/modules
          customPackagesOverlay
        ]
        ++ umport {
          paths = [
            ../nixos/features
          ];
          recursive = true;
        };
      system = architecture;
    }
  );

  mkHomeManagerUser = user: system: architecture: (
    inputs.home-manager.lib.homeManagerConfiguration {
      pkgs = pkgsFor architecture;
      extraSpecialArgs = {
        inherit inputs helper;
      };
      modules =
        [
          ../home-manager/users/${system}/${user}.nix
          ../home-manager/modules
          customPackagesOverlay
        ]
        ++ umport {
          paths = [
            ../home-manager/features
          ];
          recursive = true;
        };
    }
  );
}