added headscale service
This commit is contained in:
parent
7dfb67f1f4
commit
0e5cf34809
|
@ -92,6 +92,14 @@
|
||||||
networkInterface = "bond0";
|
networkInterface = "bond0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
nextcloud = {
|
||||||
|
enable = true;
|
||||||
|
subdomain = "drive";
|
||||||
|
};
|
||||||
|
headscale = {
|
||||||
|
enable = true;
|
||||||
|
subdomain = "vpn";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
networking = {
|
networking = {
|
||||||
hostId = "c51763d6";
|
hostId = "c51763d6";
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
imports = [];
|
|
||||||
|
|
||||||
options = {
|
|
||||||
apps = {
|
|
||||||
base_domain = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
};
|
|
||||||
headscale = {
|
|
||||||
subdomain = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "subdomain of base domain that headscale will be hosted at";
|
|
||||||
default = "headscale";
|
|
||||||
};
|
|
||||||
hostname = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "hostname that headscale will be hosted at";
|
|
||||||
default = "${config.apps.headscale.subdomain}.${config.apps.base_domain}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
nextcloud = {
|
|
||||||
subdomain = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "subdomain of base domain that nextcloud will be hosted at";
|
|
||||||
default = "nextcloud";
|
|
||||||
};
|
|
||||||
hostname = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "hostname that nextcloud will be hosted at";
|
|
||||||
default = "${config.apps.nextcloud.subdomain}.${config.apps.base_domain}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
systemd = {
|
|
||||||
services = {
|
|
||||||
headscale = {
|
|
||||||
after = ["postgresql.service"];
|
|
||||||
requires = ["postgresql.service"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services = {
|
|
||||||
# DNS stub needs to be disabled so pi hole can bind
|
|
||||||
# resolved.extraConfig = "DNSStubListener=no";
|
|
||||||
headscale = {
|
|
||||||
enable = true;
|
|
||||||
user = "headscale";
|
|
||||||
group = "headscale";
|
|
||||||
address = "0.0.0.0";
|
|
||||||
port = 8080;
|
|
||||||
settings = {
|
|
||||||
server_url = "https://${config.apps.headscale.hostname}";
|
|
||||||
dns.base_domain = "clients.${config.apps.headscale.hostname}";
|
|
||||||
logtail.enabled = true;
|
|
||||||
database = {
|
|
||||||
type = "postgres";
|
|
||||||
postgres = {
|
|
||||||
host = "/run/postgresql";
|
|
||||||
port = config.services.postgresql.settings.port;
|
|
||||||
user = "headscale";
|
|
||||||
name = "headscale";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
nginx = {
|
|
||||||
enable = true;
|
|
||||||
virtualHosts = {
|
|
||||||
${config.apps.headscale.hostname} = {
|
|
||||||
# forceSSL = true;
|
|
||||||
# enableACME = true;
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://localhost:${toString config.services.headscale.port}";
|
|
||||||
proxyWebsockets = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.systemPackages = [
|
|
||||||
config.services.headscale.package
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -10,5 +10,6 @@
|
||||||
./home-assistant.nix
|
./home-assistant.nix
|
||||||
./pihole.nix
|
./pihole.nix
|
||||||
./nextcloud.nix
|
./nextcloud.nix
|
||||||
|
./headscale.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
61
modules/nixos-modules/server/headscale.nix
Normal file
61
modules/nixos-modules/server/headscale.nix
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
hostname = "${config.host.headscale.subdomain}.${config.host.reverse_proxy.hostname}";
|
||||||
|
in {
|
||||||
|
options.host.headscale = {
|
||||||
|
enable = lib.mkEnableOption "should headscale be enabled on this computer";
|
||||||
|
subdomain = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "subdomain of base domain that headscale will be hosted at";
|
||||||
|
default = "headscale";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.host.headscale.enable {
|
||||||
|
host.reverse_proxy.subdomains.${config.host.jellyfin.subdomain} = {
|
||||||
|
target = "http://localhost:${toString config.services.headscale.port}";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = {
|
||||||
|
services = {
|
||||||
|
headscale = {
|
||||||
|
after = ["postgresql.service"];
|
||||||
|
requires = ["postgresql.service"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
|
# DNS stub needs to be disabled so pi hole can bind
|
||||||
|
# resolved.extraConfig = "DNSStubListener=no";
|
||||||
|
headscale = {
|
||||||
|
enable = true;
|
||||||
|
user = "headscale";
|
||||||
|
group = "headscale";
|
||||||
|
address = "0.0.0.0";
|
||||||
|
port = 8080;
|
||||||
|
settings = {
|
||||||
|
server_url = "https://${hostname}";
|
||||||
|
dns.base_domain = "clients.${hostname}";
|
||||||
|
logtail.enabled = true;
|
||||||
|
database = {
|
||||||
|
type = "postgres";
|
||||||
|
postgres = {
|
||||||
|
host = "/run/postgresql";
|
||||||
|
port = config.services.postgresql.settings.port;
|
||||||
|
user = "headscale";
|
||||||
|
name = "headscale";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [
|
||||||
|
config.services.headscale.package
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue