refactor(flake): inline assembly wiring
This commit is contained in:
@@ -76,13 +76,9 @@
|
|||||||
{ self, nixpkgs, ... }@inputs:
|
{ self, nixpkgs, ... }@inputs:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
flake = import ./flake { inherit lib inputs self; };
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Every host under hosts/ is discovered and built.
|
inherit (import ./flake { inherit lib inputs self; }) nixosConfigurations;
|
||||||
nixosConfigurations = flake.mkHosts {
|
|
||||||
root = self + "/hosts";
|
|
||||||
};
|
|
||||||
|
|
||||||
# A project shell for agent-local resources that should travel with this
|
# A project shell for agent-local resources that should travel with this
|
||||||
# checkout rather than the operator's global profile.
|
# checkout rather than the operator's global profile.
|
||||||
|
|||||||
@@ -4,55 +4,50 @@
|
|||||||
self,
|
self,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# TODO: refactor the registry code
|
|
||||||
registryAssembly = import ./registry.nix { inherit lib self; };
|
|
||||||
|
|
||||||
util = import ../lib { inherit lib; };
|
util = import ../lib { inherit lib; };
|
||||||
mkModules = import ./module.nix { inherit util; };
|
|
||||||
|
|
||||||
modules = mkModules {
|
registry = import ./registry.nix {
|
||||||
|
inherit lib;
|
||||||
|
hosts = self.nixosConfigurations;
|
||||||
|
root = self + "/registry";
|
||||||
|
};
|
||||||
|
|
||||||
|
modules = import ./module.nix {
|
||||||
|
inherit util;
|
||||||
root = self + "/modules";
|
root = self + "/modules";
|
||||||
};
|
};
|
||||||
|
|
||||||
guestModules = guests.mkGuests {
|
guestModules = import ./guest.nix {
|
||||||
|
inherit
|
||||||
|
inputs
|
||||||
|
lib
|
||||||
|
registry
|
||||||
|
specialArgs
|
||||||
|
util
|
||||||
|
;
|
||||||
|
repositoryModules = modules;
|
||||||
root = self + "/guests";
|
root = self + "/guests";
|
||||||
};
|
};
|
||||||
|
|
||||||
#----------------------------------------------------------
|
|
||||||
|
|
||||||
collectedRegistry = registryAssembly.collect { hosts = self.nixosConfigurations; };
|
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit
|
inherit
|
||||||
inputs
|
inputs
|
||||||
self
|
self
|
||||||
util
|
util
|
||||||
;
|
;
|
||||||
registry = collectedRegistry;
|
registry = registry.collected;
|
||||||
};
|
};
|
||||||
|
in
|
||||||
guests = import ./guest.nix {
|
{
|
||||||
inherit
|
nixosConfigurations = import ./host.nix {
|
||||||
inputs
|
|
||||||
lib
|
|
||||||
specialArgs
|
|
||||||
registryAssembly
|
|
||||||
util
|
|
||||||
;
|
|
||||||
repositoryModules = modules;
|
|
||||||
};
|
|
||||||
|
|
||||||
hosts = import ./host.nix {
|
|
||||||
inherit
|
inherit
|
||||||
inputs
|
inputs
|
||||||
lib
|
lib
|
||||||
specialArgs
|
specialArgs
|
||||||
guestModules
|
guestModules
|
||||||
registryAssembly
|
|
||||||
;
|
;
|
||||||
|
registryModule = registry.module;
|
||||||
repositoryModules = modules;
|
repositoryModules = modules;
|
||||||
|
root = self + "/hosts";
|
||||||
};
|
};
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit (hosts) mkHosts;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
lib,
|
lib,
|
||||||
|
root,
|
||||||
specialArgs,
|
specialArgs,
|
||||||
repositoryModules,
|
repositoryModules,
|
||||||
registryAssembly,
|
registry,
|
||||||
util,
|
util,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -65,7 +66,7 @@ let
|
|||||||
enable = lib.mkEnableOption "a reverse-proxy route for this guest";
|
enable = lib.mkEnableOption "a reverse-proxy route for this guest";
|
||||||
|
|
||||||
route = lib.mkOption {
|
route = lib.mkOption {
|
||||||
type = registryAssembly.definitions.route.type;
|
type = registry.types.route;
|
||||||
description = "Route registry entry published for this guest.";
|
description = "Route registry entry published for this guest.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -247,7 +248,7 @@ let
|
|||||||
inputs.stylix.nixosModules.stylix
|
inputs.stylix.nixosModules.stylix
|
||||||
|
|
||||||
repositoryModules
|
repositoryModules
|
||||||
registryAssembly.module
|
registry.module
|
||||||
cfg.interior
|
cfg.interior
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -268,15 +269,11 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
let
|
||||||
|
files = util.collectNixFiles root;
|
||||||
|
guestFiles = lib.filterAttrs (file: type: type == "regular" && lib.hasSuffix ".nix" file) (builtins.readDir root);
|
||||||
|
names = map (file: lib.removeSuffix ".nix" file) (lib.attrNames guestFiles);
|
||||||
|
in
|
||||||
{
|
{
|
||||||
mkGuests =
|
imports = files ++ map mkGuest names;
|
||||||
{ root }:
|
|
||||||
let
|
|
||||||
files = util.collectNixFiles root;
|
|
||||||
guestFiles = lib.filterAttrs (file: type: type == "regular" && lib.hasSuffix ".nix" file) (builtins.readDir root);
|
|
||||||
names = map (file: lib.removeSuffix ".nix" file) (lib.attrNames guestFiles);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = files ++ map mkGuest names;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
lib,
|
lib,
|
||||||
|
root,
|
||||||
specialArgs,
|
specialArgs,
|
||||||
repositoryModules,
|
repositoryModules,
|
||||||
|
|
||||||
guestModules,
|
guestModules,
|
||||||
# TODO refactor registry
|
registryModule,
|
||||||
registryAssembly,
|
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
mkHost =
|
mkHost =
|
||||||
@@ -26,7 +26,7 @@ let
|
|||||||
guestModules
|
guestModules
|
||||||
|
|
||||||
# TODO: refactor
|
# TODO: refactor
|
||||||
registryAssembly.module (root + "/${name}")
|
registryModule (root + "/${name}")
|
||||||
|
|
||||||
{
|
{
|
||||||
networking.hostName = name;
|
networking.hostName = name;
|
||||||
@@ -35,15 +35,11 @@ let
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
let
|
||||||
mkHosts =
|
directories = lib.filterAttrs (_name: type: type == "directory") (builtins.readDir root);
|
||||||
{ root }:
|
names = lib.attrNames directories;
|
||||||
let
|
in
|
||||||
directories = lib.filterAttrs (_name: type: type == "directory") (builtins.readDir root);
|
lib.genAttrs names (
|
||||||
names = lib.attrNames directories;
|
name:
|
||||||
in
|
mkHost { inherit root name; }
|
||||||
lib.genAttrs names (
|
)
|
||||||
name:
|
|
||||||
mkHost { inherit root name; }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{ util }:
|
{
|
||||||
{ root }:
|
root,
|
||||||
|
util,
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
imports = util.collectNixFiles root;
|
imports = util.collectNixFiles root;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user