create helpers for creating nixos system and deploy nodes
move machine definitions to separate directory
This commit is contained in:
parent
3550a6e8a8
commit
37f1e07e74
4 changed files with 34 additions and 32 deletions
36
flake.nix
36
flake.nix
|
@ -20,14 +20,16 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
|
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
|
||||||
machines = {
|
machines = import ./machines;
|
||||||
jefke = {
|
mkNixosSystems = systemDef:
|
||||||
name = "jefke";
|
nixpkgs.lib.foldlAttrs (acc: name: machine:
|
||||||
hostname = "jefke.hyp";
|
acc // {
|
||||||
user-cert = builtins.readFile ./jefke_user_ed25519-cert.pub;
|
"${name}" = nixpkgs.lib.nixosSystem (systemDef machine);
|
||||||
host-cert = builtins.readFile ./jefke_host_ed25519-cert.pub;
|
}) { } machines;
|
||||||
};
|
mkDeployNodes = nodeDef:
|
||||||
};
|
nixpkgs.lib.foldlAttrs
|
||||||
|
(acc: name: machine: acc // { "${name}" = nodeDef machine; }) { }
|
||||||
|
machines;
|
||||||
in {
|
in {
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
|
@ -40,10 +42,7 @@
|
||||||
# TODO. if uncommented, nix flake check fails
|
# TODO. if uncommented, nix flake check fails
|
||||||
# formatter = pkgs.nixfmt;
|
# formatter = pkgs.nixfmt;
|
||||||
|
|
||||||
# TODO create helper
|
nixosConfigurations = mkNixosSystems (machine: {
|
||||||
nixosConfigurations = nixpkgs.lib.foldlAttrs (acc: name: machine:
|
|
||||||
acc // {
|
|
||||||
"${name}" = nixpkgs.lib.nixosSystem {
|
|
||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = { inherit machine; };
|
specialArgs = { inherit machine; };
|
||||||
modules = [
|
modules = [
|
||||||
|
@ -51,24 +50,19 @@
|
||||||
agenix.nixosModules.default
|
agenix.nixosModules.default
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
];
|
];
|
||||||
};
|
});
|
||||||
}) { } machines;
|
|
||||||
|
|
||||||
deploy = {
|
deploy = {
|
||||||
sshUser = "root";
|
sshUser = "root";
|
||||||
user = "root";
|
user = "root";
|
||||||
|
|
||||||
# TODO create helper
|
nodes = mkDeployNodes (machine: {
|
||||||
nodes = nixpkgs.lib.foldlAttrs (acc: name: machine:
|
|
||||||
acc // {
|
|
||||||
"${name}" = {
|
|
||||||
hostname = machine.hostname;
|
hostname = machine.hostname;
|
||||||
profiles.hypervisor = {
|
profiles.hypervisor = {
|
||||||
path = deploy-rs.lib.${system}.activate.nixos
|
path = deploy-rs.lib.${system}.activate.nixos
|
||||||
self.nixosConfigurations.${name};
|
self.nixosConfigurations.${machine.name};
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
}) { } machines;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = builtins.mapAttrs
|
checks = builtins.mapAttrs
|
||||||
|
|
8
machines/default.nix
Normal file
8
machines/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
jefke = {
|
||||||
|
name = "jefke";
|
||||||
|
hostname = "jefke.hyp";
|
||||||
|
user-cert = builtins.readFile ./jefke_user_ed25519-cert.pub;
|
||||||
|
host-cert = builtins.readFile ./jefke_host_ed25519-cert.pub;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue