refactor(deploy): move deployment config into '<host>/meta.nix'
This commit is contained in:
@@ -8,19 +8,15 @@ let
|
||||
utils = import ../utils { inherit lib; };
|
||||
hostDirNames = utils.dirNames ../hosts;
|
||||
|
||||
mkNode = hostname: tags: {
|
||||
mkNode = hostname: meta: {
|
||||
imports = [ ../hosts/${hostname} ];
|
||||
deployment = {
|
||||
targetHost = self.nixosConfigurations.${hostname}.config.ssh.publicHostname;
|
||||
targetUser = self.nixosConfigurations.${hostname}.config.host.username;
|
||||
buildOnTarget = builtins.any (t: t != "local" && t != "arm") tags;
|
||||
inherit tags;
|
||||
inherit (meta.deployment) targetHost targetUser tags;
|
||||
buildOnTarget = builtins.any (t: t != "local" && t != "arm") meta.deployment.tags;
|
||||
};
|
||||
};
|
||||
|
||||
nodes = lib.genAttrs hostDirNames (
|
||||
hostname: mkNode hostname (utils.hostMeta ../hosts/${hostname}).deployment.tags
|
||||
);
|
||||
nodes = lib.genAttrs hostDirNames (hostname: mkNode hostname (utils.hostMeta ../hosts/${hostname}));
|
||||
in
|
||||
inputs.colmena.lib.makeHive (
|
||||
{
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
{
|
||||
outputs,
|
||||
myUtils,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
nixosConfigs = builtins.attrNames outputs.nixosConfigurations;
|
||||
homeConfigs = map (n: lib.last (lib.splitString "@" n)) (
|
||||
builtins.attrNames outputs.homeConfigurations
|
||||
);
|
||||
allHosts = lib.unique (homeConfigs ++ nixosConfigs);
|
||||
hostDir = ../../hosts;
|
||||
hostNames = myUtils.dirNames hostDir;
|
||||
hostsWithKeys = lib.filter (
|
||||
hostname: builtins.pathExists ../../hosts/${hostname}/ssh_host.pub
|
||||
) allHosts;
|
||||
hostname: builtins.pathExists (hostDir + "/${hostname}/ssh_host.pub")
|
||||
) hostNames;
|
||||
in
|
||||
{
|
||||
home.packages = with pkgs; [ sshfs ];
|
||||
@@ -25,15 +22,14 @@ in
|
||||
lib.genAttrs hostsWithKeys (
|
||||
hostname:
|
||||
let
|
||||
hostConfig = outputs.nixosConfigurations.${hostname}.config;
|
||||
inherit (hostConfig.ssh) publicHostname username;
|
||||
meta = myUtils.hostMeta (hostDir + "/${hostname}");
|
||||
in
|
||||
{
|
||||
host = hostname;
|
||||
user = username;
|
||||
user = meta.deployment.targetUser;
|
||||
}
|
||||
// lib.optionalAttrs (publicHostname != "") {
|
||||
hostname = publicHostname;
|
||||
// lib.optionalAttrs (meta.deployment.targetHost != "") {
|
||||
hostname = meta.deployment.targetHost;
|
||||
}
|
||||
)
|
||||
// {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
system = "x86_64-linux";
|
||||
deployment.tags = [ "local" ];
|
||||
deployment = {
|
||||
tags = [ "local" ];
|
||||
targetHost = "";
|
||||
targetUser = "h";
|
||||
};
|
||||
role = "desktop";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
system = "x86_64-linux";
|
||||
deployment.tags = [ "local" ];
|
||||
deployment = {
|
||||
tags = [ "local" ];
|
||||
targetHost = "";
|
||||
targetUser = "h";
|
||||
};
|
||||
role = "laptop";
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
];
|
||||
|
||||
ssh = {
|
||||
publicHostname = config.host.name;
|
||||
authorizedHosts = [
|
||||
"andromache"
|
||||
"astyanax"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
system = "aarch64-linux";
|
||||
deployment.tags = [ "arm" ];
|
||||
deployment = {
|
||||
tags = [ "arm" ];
|
||||
targetHost = "eetion-02";
|
||||
targetUser = "h";
|
||||
};
|
||||
role = "embedded";
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
];
|
||||
|
||||
ssh = {
|
||||
publicHostname = config.host.name;
|
||||
authorizedHosts = [
|
||||
"andromache"
|
||||
"astyanax"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
system = "aarch64-linux";
|
||||
deployment.tags = [ "arm" ];
|
||||
deployment = {
|
||||
tags = [ "arm" ];
|
||||
targetHost = "eetion";
|
||||
targetUser = "h";
|
||||
};
|
||||
role = "embedded";
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
networking.hostName = config.host.name;
|
||||
ssh = {
|
||||
publicHostname = "server.hektormisplon.xyz";
|
||||
authorizedHosts = [
|
||||
"andromache"
|
||||
"astyanax"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
system = "x86_64-linux";
|
||||
deployment.tags = [ "cloud" ];
|
||||
deployment = {
|
||||
tags = [ "cloud" ];
|
||||
targetHost = "server.hektormisplon.xyz";
|
||||
targetUser = "username";
|
||||
};
|
||||
role = "server";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{
|
||||
system = "x86_64-linux";
|
||||
deployment.tags = [ "local" ];
|
||||
deployment = {
|
||||
tags = [ "local" ];
|
||||
targetHost = "";
|
||||
targetUser = "h";
|
||||
};
|
||||
role = "vm";
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ in
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
};
|
||||
publicHostname = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
|
||||
# auto generate authorized_keys from `authorizedHosts`
|
||||
|
||||
Reference in New Issue
Block a user