feat: add host device type metadata
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user