old
1{
2 self,
3 colmena,
4 nixpkgs,
5 ...
6} @ inputs: let
7 inherit (inputs.nixpkgs) lib;
8 mylib = import ../lib {inherit lib;};
9 myvars = import ../vars {inherit lib;};
10
11 # Add my custom lib, vars, nixpkgs instance, and all the inputs to specialArgs,
12 # so that I can use them in all my nixos/home-manager modules.
13 genSpecialArgs = system:
14 inputs
15 // {
16 inherit mylib myvars;
17
18 # use unstable branch for some packages to get the latest updates
19 pkgs-unstable = import inputs.nixpkgs-unstable {
20 inherit system; # refer the `system` parameter form outer scope recursively
21 config.allowUnfree = true;
22 };
23 pkgs-stable = import inputs.nixpkgs-stable {
24 inherit system;
25 config.allowUnfree = true;
26 };
27 };
28
29 # This is the args for all the haumea modules in this folder.
30 args = {
31 inherit
32 inputs
33 lib
34 mylib
35 myvars
36 genSpecialArgs
37 ;
38 };
39
40 nixosSystems = {
41 x86_64-linux = import ./x86_64-linux (args // {system = "x86_64-linux";});
42 };
43
44 darwinSystems = {};
45 allSystems = nixosSystems // darwinSystems;
46 allSystemNames = builtins.attrNames allSystems;
47 nixosSystemValues = builtins.attrValues nixosSystems;
48 darwinSystemValues = builtins.attrValues darwinSystems;
49 allSystemValues = nixosSystemValues ++ darwinSystemValues;
50
51 # Helper function to generate a set of attributes for each system
52 forAllSystems = func: (nixpkgs.lib.genAttrs allSystemNames func);
53in {
54 # Add attribute sets into outputs, for debugging
55 debugAttrs = {
56 inherit
57 nixosSystems
58 darwinSystems
59 allSystems
60 allSystemNames
61 ;
62 };
63
64 # NixOS Hosts
65 nixosConfigurations = lib.attrsets.mergeAttrsList (
66 map (it: it.nixosConfigurations or {}) nixosSystemValues
67 );
68
69 # Colmena - remote deployment via SSH
70 colmenaHive = colmena.lib.makeHive self.outputs.colmena;
71 colmena =
72 {
73 meta =
74 (
75 let
76 system = "x86_64-linux";
77 in {
78 # colmena's default nixpkgs & specialArgs
79 nixpkgs = import nixpkgs {inherit system;};
80 specialArgs = genSpecialArgs system;
81 }
82 )
83 // {
84 # per-node nixpkgs & specialArgs
85 nodeNixpkgs = lib.attrsets.mergeAttrsList (map (it: it.colmenaMeta.nodeNixpkgs or {}) nixosSystemValues);
86 nodeSpecialArgs = lib.attrsets.mergeAttrsList (map (it: it.colmenaMeta.nodeSpecialArgs or {}) nixosSystemValues);
87 };
88 }
89 // lib.attrsets.mergeAttrsList (map (it: it.colmena or {}) nixosSystemValues);
90
91 # macOS Hosts
92 darwinConfigurations = lib.attrsets.mergeAttrsList (
93 map (it: it.darwinConfigurations or {}) darwinSystemValues
94 );
95
96 # Packages
97 packages = forAllSystems (system: allSystems.${system}.packages or {});
98}