refactor: merge 'host.nix' into 'meta.nix'
This commit is contained in:
@@ -8,16 +8,24 @@ let
|
|||||||
utils = import ../utils { inherit lib; };
|
utils = import ../utils { inherit lib; };
|
||||||
hostnames = utils.dirNames ../hosts;
|
hostnames = utils.dirNames ../hosts;
|
||||||
|
|
||||||
mkNode = hostname: meta: {
|
mkNode =
|
||||||
imports = [ ../hosts/${hostname} ];
|
hostname:
|
||||||
host.name = hostname;
|
let
|
||||||
deployment = {
|
meta = utils.hostMeta ../hosts/${hostname};
|
||||||
inherit (meta.deployment) targetHost targetUser tags;
|
isLocal = builtins.elem "local" meta.tags;
|
||||||
buildOnTarget = builtins.any (t: t != "local" && t != "arm") meta.deployment.tags;
|
in
|
||||||
|
{
|
||||||
|
imports = [ ../hosts/${hostname} ];
|
||||||
|
host.name = hostname;
|
||||||
|
deployment = {
|
||||||
|
inherit (meta) tags;
|
||||||
|
targetUser = meta.host.username;
|
||||||
|
targetHost = if isLocal then "" else hostname;
|
||||||
|
buildOnTarget = builtins.any (t: t != "local" && t != "arm") meta.tags;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
nodes = lib.genAttrs hostnames (hostname: mkNode hostname (utils.hostMeta ../hosts/${hostname}));
|
nodes = lib.genAttrs hostnames mkNode;
|
||||||
in
|
in
|
||||||
inputs.colmena.lib.makeHive (
|
inputs.colmena.lib.makeHive (
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,12 +29,13 @@ in
|
|||||||
hostname:
|
hostname:
|
||||||
let
|
let
|
||||||
meta = myUtils.hostMeta (hostDir + "/${hostname}");
|
meta = myUtils.hostMeta (hostDir + "/${hostname}");
|
||||||
|
isLocal = builtins.elem "local" meta.tags;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
User = meta.deployment.targetUser;
|
User = meta.host.username;
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (meta.deployment.targetHost != "") {
|
// lib.optionalAttrs (!isLocal) {
|
||||||
HostName = meta.deployment.targetHost;
|
HostName = hostname;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
meta = import ./meta.nix;
|
||||||
wolInterfaces = import ./wol-interfaces.nix;
|
wolInterfaces = import ./wol-interfaces.nix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
./hard.nix
|
./hard.nix
|
||||||
./host.nix
|
|
||||||
inputs.nixos-hardware.nixosModules.common-cpu-intel
|
inputs.nixos-hardware.nixosModules.common-cpu-intel
|
||||||
inputs.nixos-hardware.nixosModules.common-pc
|
inputs.nixos-hardware.nixosModules.common-pc
|
||||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||||
@@ -24,6 +24,8 @@ in
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
inherit (meta) host;
|
||||||
|
|
||||||
home-manager.users.${config.host.username} = import ../../home/hosts/${config.host.name};
|
home-manager.users.${config.host.username} = import ../../home/hosts/${config.host.name};
|
||||||
|
|
||||||
"ai-tools".enable = true;
|
"ai-tools".enable = true;
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
host = {
|
|
||||||
username = "h";
|
|
||||||
highRam = true;
|
|
||||||
admin = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
deployment = {
|
|
||||||
tags = [ "local" ];
|
|
||||||
targetHost = "";
|
|
||||||
targetUser = "h";
|
|
||||||
};
|
|
||||||
role = "desktop";
|
role = "desktop";
|
||||||
|
tags = [ "local" ];
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
highRam = true;
|
||||||
|
admin = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,13 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
meta = import ./meta.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
./hard.nix
|
./hard.nix
|
||||||
./host.nix
|
|
||||||
inputs.nixos-hardware.nixosModules.common-pc
|
inputs.nixos-hardware.nixosModules.common-pc
|
||||||
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
inputs.nixos-hardware.nixosModules.common-pc-ssd
|
||||||
# inputs.nixos-hardware.nixosModules.lenovo-thinkpad-e14-intel-gen7 (not available yet?)
|
# inputs.nixos-hardware.nixosModules.lenovo-thinkpad-e14-intel-gen7 (not available yet?)
|
||||||
@@ -21,6 +23,8 @@
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
inherit (meta) host;
|
||||||
|
|
||||||
home-manager.users.${config.host.username} = import ../../home/hosts/${config.host.name};
|
home-manager.users.${config.host.username} = import ../../home/hosts/${config.host.name};
|
||||||
|
|
||||||
"ai-tools".enable = true;
|
"ai-tools".enable = true;
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
host = {
|
|
||||||
username = "h";
|
|
||||||
highRam = true;
|
|
||||||
admin = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
deployment = {
|
|
||||||
tags = [ "local" ];
|
|
||||||
targetHost = "";
|
|
||||||
targetUser = "h";
|
|
||||||
};
|
|
||||||
role = "laptop";
|
role = "laptop";
|
||||||
|
tags = [ "local" ];
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
highRam = true;
|
||||||
|
admin = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,17 @@
|
|||||||
# Raspberry Pi 3
|
# Raspberry Pi 3
|
||||||
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_3>
|
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_3>
|
||||||
|
|
||||||
|
let
|
||||||
|
meta = import ./meta.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hard.nix
|
./hard.nix
|
||||||
./host.nix
|
|
||||||
../../modules
|
../../modules
|
||||||
];
|
];
|
||||||
|
|
||||||
|
inherit (meta) host;
|
||||||
|
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
host = {
|
|
||||||
username = "h";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
deployment = {
|
|
||||||
tags = [ "arm" ];
|
|
||||||
targetHost = "eetion-02";
|
|
||||||
targetUser = "h";
|
|
||||||
};
|
|
||||||
role = "embedded";
|
role = "embedded";
|
||||||
|
tags = [ "arm" ];
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,17 @@
|
|||||||
# Orange Pi Zero2 H616
|
# Orange Pi Zero2 H616
|
||||||
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Orange_Pi_Zero2_H616>
|
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Orange_Pi_Zero2_H616>
|
||||||
|
|
||||||
|
let
|
||||||
|
meta = import ./meta.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hard.nix
|
./hard.nix
|
||||||
./host.nix
|
|
||||||
../../modules
|
../../modules
|
||||||
];
|
];
|
||||||
|
|
||||||
|
inherit (meta) host;
|
||||||
|
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
host = {
|
|
||||||
username = "h";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
deployment = {
|
|
||||||
tags = [ "arm" ];
|
|
||||||
targetHost = "eetion";
|
|
||||||
targetUser = "h";
|
|
||||||
};
|
|
||||||
role = "embedded";
|
role = "embedded";
|
||||||
|
tags = [ "arm" ];
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,19 @@
|
|||||||
|
|
||||||
# also see <https://wiki.nixos.org/wiki/Install_NixOS_on_Hetzner_Cloud>
|
# also see <https://wiki.nixos.org/wiki/Install_NixOS_on_Hetzner_Cloud>
|
||||||
|
|
||||||
|
let
|
||||||
|
meta = import ./meta.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
./hard.nix
|
./hard.nix
|
||||||
inputs.comin.nixosModules.comin
|
inputs.comin.nixosModules.comin
|
||||||
./host.nix
|
|
||||||
../../modules
|
../../modules
|
||||||
];
|
];
|
||||||
|
|
||||||
docker.enable = true;
|
inherit (meta) host;
|
||||||
|
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
host = {
|
|
||||||
username = "username";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
deployment = {
|
|
||||||
tags = [ "cloud" ];
|
|
||||||
targetHost = "hecuba";
|
|
||||||
targetUser = "username";
|
|
||||||
};
|
|
||||||
role = "server";
|
role = "server";
|
||||||
|
tags = [ "cloud" ];
|
||||||
|
host = {
|
||||||
|
username = "username";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,19 @@
|
|||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
meta = import ./meta.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
./hard.nix
|
./hard.nix
|
||||||
./host.nix
|
|
||||||
./disk.nix
|
./disk.nix
|
||||||
../../modules
|
../../modules
|
||||||
];
|
];
|
||||||
|
|
||||||
|
inherit (meta) host;
|
||||||
|
|
||||||
home-manager.users.${config.host.username} = import ../../home/hosts/vm;
|
home-manager.users.${config.host.username} = import ../../home/hosts/vm;
|
||||||
|
|
||||||
"ai-tools".enable = true;
|
"ai-tools".enable = true;
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
host = {
|
|
||||||
username = "h";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
deployment = {
|
|
||||||
tags = [ "local" ];
|
|
||||||
targetHost = "";
|
|
||||||
targetUser = "h";
|
|
||||||
};
|
|
||||||
role = "vm";
|
role = "vm";
|
||||||
|
tags = [ "local" ];
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ in
|
|||||||
if builtins.pathExists (hostDir + "/meta.nix") then
|
if builtins.pathExists (hostDir + "/meta.nix") then
|
||||||
import (hostDir + "/meta.nix")
|
import (hostDir + "/meta.nix")
|
||||||
else
|
else
|
||||||
throw "meta.nix required in ${hostDir}";
|
throw "meta.nix required in ${toString hostDir}";
|
||||||
|
|
||||||
adminHosts =
|
adminHosts =
|
||||||
hostsPath:
|
hostsPath:
|
||||||
builtins.filter (host: ((import (hostsPath + "/${host}/host.nix")).host.admin or false)) (
|
builtins.filter (host: ((import (hostsPath + "/${host}/meta.nix")).host.admin or false)) (
|
||||||
fs.dirNames hostsPath
|
fs.dirNames hostsPath
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user