refactor(nixos:tailcale): move options --> ooknet.host.networking.tailscale

This commit is contained in:
ooks-io 2024-06-12 22:32:58 +12:00
parent fa926b9453
commit dd6271f7d6
7 changed files with 195 additions and 224 deletions

View file

@ -1,42 +1,14 @@
{ lib, config, pkgs, ... }:
let
cfg = config.ooknet.networking.tailscale;
cfg = config.ooknet.host.networking.tailscale;
inherit (config.services) tailscale;
inherit (lib.lists) optionals;
inherit (lib.types) bool listOf str;
inherit (lib.strings) concatStringsSep;
inherit (lib) mkIf mkEnableOption mkOption mkDefault;
inherit (lib) mkIf mkDefault;
in
{
options.ooknet.networking.tailscale = {
enable = mkEnableOption "Enable tailscale system module";
server = mkOption {
type = bool;
default = false;
description = "Define if the host is a server";
};
client = mkOption {
type = bool;
default = cfg.enable;
description = "Define if the host is a client";
};
tag = mkOption {
type = listOf str;
default =
if cfg.client then ["tag:client"]
else if cfg.server then ["tag:server"]
else [];
description = "Sets host tag depending on if server/client";
};
operator = mkOption {
type = str;
default = "ooks";
description = "Name of the tailscale operator";
};
};
config = mkIf cfg.enable {
services.tailscale = {

View file

@ -3,7 +3,9 @@
let
inherit (lib) mkOption mkEnableOption;
inherit (lib.types) bool enum listOf int submodule nullOr str;
admin = config.ooknet.host.admin;
hardware = config.ooknet.host.hardware;
tailscale = config.ooknet.host.networking.tailscale;
in
{
@ -24,7 +26,7 @@ in
};
profiles = mkOption {
type = listOf (enum ["gaming" "creative" "productivity" "media-server"]);
type = listOf (enum ["gaming" "creative" "productivity" "console-tools" "media-server"]);
default = [];
};
@ -52,6 +54,35 @@ in
homeManager = mkEnableOption "";
};
networking = {
tailscale = {
enable = mkEnableOption "Enable tailscale system module";
server = mkOption {
type = bool;
default = false;
description = "Define if the host is a server";
};
client = mkOption {
type = bool;
default = tailscale.enable;
description = "Define if the host is a client";
};
tag = mkOption {
type = listOf str;
default =
if tailscale.client then ["tag:client"]
else if tailscale.server then ["tag:server"]
else [];
description = "Sets host tag depending on if server/client";
};
operator = mkOption {
type = str;
default = "${admin.name}";
description = "Name of the tailscale operator";
};
};
};
hardware = {
gpu = {
type = mkOption {