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