removed headscale

This commit is contained in:
Leyla Becker 2025-01-03 16:34:15 -06:00
parent 0e5cf34809
commit da8919b999
4 changed files with 39 additions and 102 deletions

View file

@ -1,9 +1,5 @@
# server nas # server nas
{pkgs, ...}: { {pkgs, ...}: {
imports = [
# ./services.nix
];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
host = { host = {
@ -65,6 +61,13 @@
enable = false; enable = false;
hostname = "volpe.social"; hostname = "volpe.social";
}; };
postgres = {
extraUsers = {
leyla = {
isAdmin = true;
};
};
};
jellyfin = { jellyfin = {
enable = true; enable = true;
subdomain = "media"; subdomain = "media";
@ -96,40 +99,11 @@
enable = true; enable = true;
subdomain = "drive"; subdomain = "drive";
}; };
headscale = {
enable = true;
subdomain = "vpn";
};
}; };
networking = { networking = {
hostId = "c51763d6"; hostId = "c51763d6";
}; };
# apps = {
# base_domain = "jan-leila.com";
# macvlan = {
# subnet = "192.168.1.0/24";
# gateway = "192.168.1.1";
# networkInterface = "bond0";
# };
# pihole = {
# image = "pihole/pihole:2024.07.0";
# ip = "192.168.1.201";
# };
# headscale = {
# subdomain = "vpn";
# };
# jellyfin = {
# subdomain = "media";
# };
# forgejo = {
# subdomain = "git";
# };
# nextcloud = {
# subdomain = "drive";
# };
# };
services = { services = {
# TODO: move zfs scrubbing into module # TODO: move zfs scrubbing into module
zfs = { zfs = {

View file

@ -10,6 +10,5 @@
./home-assistant.nix ./home-assistant.nix
./pihole.nix ./pihole.nix
./nextcloud.nix ./nextcloud.nix
./headscale.nix
]; ];
} }

View file

@ -1,61 +0,0 @@
{
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
];
};
}

View file

@ -7,6 +7,8 @@
dataDir = "/var/lib/postgresql/15"; dataDir = "/var/lib/postgresql/15";
adminUsers = lib.lists.filter (user: user.isAdmin) (lib.attrsets.mapAttrsToList (_: user: user) config.host.postgres.extraUsers); adminUsers = lib.lists.filter (user: user.isAdmin) (lib.attrsets.mapAttrsToList (_: user: user) config.host.postgres.extraUsers);
clientUsers = lib.lists.filter (user: user.isClient) (lib.attrsets.mapAttrsToList (_: user: user) config.host.postgres.extraUsers); clientUsers = lib.lists.filter (user: user.isClient) (lib.attrsets.mapAttrsToList (_: user: user) config.host.postgres.extraUsers);
createUsers = lib.lists.filter (user: user.createUser) (lib.attrsets.mapAttrsToList (_: user: user) config.host.postgres.extraUsers);
createDatabases = lib.attrsets.mapAttrsToList (_: user: user) config.host.postgres.extraDatabases;
in { in {
options = { options = {
host.postgres = { host.postgres = {
@ -26,6 +28,21 @@ in {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
}; };
createUser = lib.mkOption {
type = lib.types.bool;
default = false;
};
};
}));
default = {};
};
extraDatabases = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule ({name, ...}: {
options = {
name = lib.mkOption {
type = lib.types.str;
default = name;
};
}; };
})); }));
default = {}; default = {};
@ -39,11 +56,19 @@ in {
postgresql = { postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_15; package = pkgs.postgresql_15;
ensureUsers = [ ensureUsers =
[
{ {
name = "postgres"; name = "postgres";
} }
]; ]
++ (
builtins.map (user: {
name = user.name;
})
createUsers
);
ensureDatabases = builtins.map (database: database.name) createDatabases;
identMap = identMap =
'' ''
# ArbitraryMapName systemUser DBUser # ArbitraryMapName systemUser DBUser
@ -60,13 +85,13 @@ in {
# Client Users # Client Users
'' ''
+ ( + (
lib.strings.concatLines (builtins.map (user: "superuser_map ${user.name} ${user.name}") clientUsers) lib.strings.concatLines (builtins.map (user: "user_map ${user.name} ${user.name}") clientUsers)
); );
# configuration here lets users access the db that matches their name and lets user postgres access everything # configuration here lets users access the db that matches their name and lets user postgres access everything
authentication = pkgs.lib.mkOverride 10 '' authentication = pkgs.lib.mkOverride 10 ''
# type database DBuser origin-address auth-method optional_ident_map # type database DBuser origin-address auth-method optional_ident_map
local all postgres peer map=superuser_map local all postgres peer map=superuser_map
local sameuser all peer map=superuser_map local sameuser all peer map=user_map
''; '';
}; };
}; };