refactor: move tailscale to services
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.nih.networking;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./tailscale.nix
|
||||
];
|
||||
options.nih.networking = with lib; with lib.types; {
|
||||
defaultGateway = mkOption {
|
||||
type = str;
|
||||
@@ -45,9 +42,8 @@ in
|
||||
boot.kernel.sysctl."net.ipv4.ip_forward" = if cfg.portForwarding then 1 else 0;
|
||||
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = if cfg.portForwarding then 1 else 0;
|
||||
|
||||
host.networking.hostName = cfg.hostName;
|
||||
|
||||
networking = {
|
||||
hostName = cfg.hostName;
|
||||
defaultGateway = cfg.defaultGateway;
|
||||
dhcpcd.enable = true;
|
||||
interfaces = mkIf (cfg.interface != null) {
|
||||
@@ -56,9 +52,7 @@ in
|
||||
prefixLength = 28;
|
||||
}];
|
||||
};
|
||||
nameservers = [
|
||||
(mkIf config.nih.networking.tailscale.enable "100.100.100.100")
|
||||
] ++ cfg.nameservers;
|
||||
nameservers = cfg.nameservers;
|
||||
networkmanager.enable = cfg.networkmanager;
|
||||
wireless.enable = cfg.wireless;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
./adguard.nix
|
||||
./caddy.nix
|
||||
./forgejo.nix
|
||||
./tailscale.nix
|
||||
];
|
||||
options.nih.services = { };
|
||||
config = { };
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.nih.networking.tailscale;
|
||||
cfg = config.nih.services.tailscale;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.nih.networking.tailscale = with lib; with lib.types; {
|
||||
options.nih.services.tailscale = with lib; with lib.types; {
|
||||
enable = mkEnableOption "";
|
||||
exitNode = mkOption {
|
||||
type = bool;
|
||||
@@ -19,6 +19,14 @@ in
|
||||
type = enum [ "none" "client" "server" "both" ];
|
||||
default = "client";
|
||||
};
|
||||
tailnetName = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
apply = v:
|
||||
if cfg.enable && config.nih.handleDomains && v == null then
|
||||
throw "The option ${tailnetName} a is used when Tailscale and Nih's domain handling is enabled, but it is not defined."
|
||||
else null;
|
||||
};
|
||||
upFlags = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
@@ -36,6 +44,7 @@ in
|
||||
|
||||
nih.networking = mkIf cfg.exitNode {
|
||||
portForwarding = mkDefault true;
|
||||
nameservers = [ "100.100.100.100" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user