feat: add host device type metadata

This commit is contained in:
2026-04-21 01:42:32 +02:00
parent 4008fde198
commit 2572022349
6 changed files with 13 additions and 32 deletions
+3 -4
View File
@@ -3,13 +3,12 @@
flake.modules.nixos.openssh = flake.modules.nixos.openssh =
{ {
config, config,
hostType ? "desktop",
lib, lib,
host ? {
isServer = false;
},
... ...
}: }:
let let
isServer = hostType == "server";
hostUserNames = builtins.attrNames ( hostUserNames = builtins.attrNames (
lib.filterAttrs (_: user: user.isNormalUser or false) config.users.users lib.filterAttrs (_: user: user.isNormalUser or false) config.users.users
); );
@@ -17,7 +16,7 @@
{ {
services.openssh = { services.openssh = {
enable = true; enable = true;
openFirewall = host.isServer; openFirewall = isServer;
settings = { settings = {
PermitRootLogin = "no"; PermitRootLogin = "no";
PasswordAuthentication = false; PasswordAuthentication = false;
+1 -6
View File
@@ -9,13 +9,8 @@ in
{ {
flake.modules.nixos.orion = flake.modules.nixos.orion =
{ pkgs, ... }: { pkgs, ... }:
let
host = {
isServer = true;
};
in
{ {
_module.args.host = host; _module.args.hostType = "server";
imports = [ imports = [
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
+1 -6
View File
@@ -14,13 +14,8 @@ in
pkgs, pkgs,
... ...
}: }:
let
host = {
isServer = false;
};
in
{ {
_module.args.host = host; _module.args.hostType = "desktop";
imports = [ imports = [
nixosModules.desktopBase nixosModules.desktopBase
+1 -6
View File
@@ -10,13 +10,8 @@ in
{ {
flake.modules.nixos.zenith = flake.modules.nixos.zenith =
{ ... }: { ... }:
let
host = {
isServer = false;
};
in
{ {
_module.args.host = host; _module.args.hostType = "laptop";
imports = [ imports = [
nixosModules.desktopBase nixosModules.desktopBase
+3 -5
View File
@@ -8,15 +8,13 @@ in
{ {
flake.modules.nixos.sopsHost = flake.modules.nixos.sopsHost =
{ {
hostType ? "desktop",
lib, lib,
host ? {
isServer = false;
},
... ...
}: }:
let let
useHostSshKey = host.isServer; useHostSshKey = hostType == "server";
useAdminKeyFile = !host.isServer; useAdminKeyFile = hostType != "server";
adminKeyDir = builtins.dirOf sopsAdminKeyPath; adminKeyDir = builtins.dirOf sopsAdminKeyPath;
in in
{ {
+4 -5
View File
@@ -24,18 +24,17 @@ let
{ accountName }: { accountName }:
{ {
config, config,
host ? { hostType ? "desktop",
isServer = false;
},
lib, lib,
pkgs, pkgs,
... ...
}: }:
let let
account = accounts.${accountName}; account = accounts.${accountName};
isServer = hostType == "server";
in in
{ {
sops.secrets = lib.optionalAttrs (!host.isServer) { sops.secrets = lib.optionalAttrs (!isServer) {
"hashed-password-${accountName}".neededForUsers = true; "hashed-password-${accountName}".neededForUsers = true;
}; };
@@ -51,7 +50,7 @@ let
"networkmanager" "networkmanager"
]; ];
} }
// lib.optionalAttrs (!host.isServer) { // lib.optionalAttrs (!isServer) {
hashedPasswordFile = config.sops.secrets."hashed-password-${accountName}".path; hashedPasswordFile = config.sops.secrets."hashed-password-${accountName}".path;
}; };