Clean up helpers.nix

This commit is contained in:
Fern Garden 2025-08-27 15:41:59 +08:00
parent 7417d91809
commit ecbddad7a7

View file

@ -12,13 +12,14 @@ with inputs.nixpkgs.lib; {
suite ? "", suite ? "",
docker ? false, docker ? false,
hostModules ? [], hostModules ? [],
}: }: let
{ # Secrets directory.
nixosConfigurations.${hostname} = nixosSystem rec { secrets = builtins.toString inputs.secrets;
# Architecture. # Architecture.
system = platform; system = platform;
# nixpkgs config. # Stable nixpkgs with overlay.
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
@ -38,12 +39,27 @@ with inputs.nixpkgs.lib; {
]; ];
}; };
specialArgs = { # deploy-rs.
# Pass hostname & inputs to config. deployPkgs = import nixpkgs {
inherit inputs hostname; inherit system;
# Secrets directory. overlays = [
secrets = builtins.toString inputs.secrets; deploy-rs.overlays.default
(self: super: {
deploy-rs = {
inherit (pkgs) deploy-rs;
lib = super.deploy-rs.lib;
};
})
];
};
in {
nixosConfigurations.${hostname} = nixosSystem {
inherit system pkgs;
specialArgs = {
# Pass variables to config.
inherit inputs secrets hostname;
}; };
modules = modules =
@ -83,22 +99,8 @@ with inputs.nixpkgs.lib; {
++ optionals (docker == true) [./suites/server/docker] # Enable docker if required. ++ optionals (docker == true) [./suites/server/docker] # Enable docker if required.
++ (filesystem.listFilesRecursive ./modules); # Custom modules. ++ (filesystem.listFilesRecursive ./modules); # Custom modules.
}; };
}
// optionalAttrs (strings.hasPrefix "server" suite) { deploy.nodes.${hostname} = mkIf (strings.hasPrefix "server" suite) {
deploy.nodes.${hostname} = let
deployPkgs = import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlays.default
(self: super: {
deploy-rs = {
inherit (pkgs) deploy-rs;
lib = super.deploy-rs.lib;
};
})
];
};
in {
hostname = "${hostname}.local"; hostname = "${hostname}.local";
profiles.system = { profiles.system = {
user = "root"; user = "root";