updates to vault and tailscale

This commit is contained in:
RingOfStorms (Joshua Bell) 2025-03-11 09:22:06 -05:00
parent 0635ee5954
commit 18148b03af
3 changed files with 51 additions and 57 deletions

View file

@ -28,6 +28,7 @@
# https://tailscale.com/kb/1241/tailscale-up
extraUpFlags = lib.mkIf config.components.tailscale.useHeadscale [
"--login-server=https://headscale.joshuabell.xyz"
"--no-logs-support"
];
};
networking.firewall.trustedInterfaces = [ config.services.tailscale.interfaceName ];

View file

@ -66,6 +66,14 @@
# Allow emulation of aarch64-linux binaries for cross compiling
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
programs._1password.enable = true;
programs._1password-gui = {
enable = true;
# Certain features, including CLI integration and system authentication support,
# require enabling PolKit integration on some desktop environments (e.g. Plasma).
polkitPolicyOwners = [ "josh" ];
};
mods = {
common = {
disableRemoteBuildsOnLio = true;
@ -99,6 +107,7 @@
openscad
vlc
bitwarden
vaultwarden
];
};
};

View file

@ -1,85 +1,69 @@
{
lib,
config,
...
}:
let
name = "vaultwarden";
hostDataDir = "/var/lib/${name}";
hostAddress = "192.168.100.2";
localAddress = "192.168.100.111";
binds = [
{
host = "${hostDataDir}";
container = "/data";
user = "vaultwarden";
user = name;
uid = 114;
}
];
hostDataDir = "/var/lib/${name}";
v_port = 8222;
in
{
users = lib.foldl (
acc: bind:
{
users.${bind.user} = {
users = {
users.${user} = {
isSystemUser = true;
home = bind.host;
createHome = true;
group = bind.user;
uid = bind.uid;
group = user;
inherit uid;
};
groups.${bind.user}.gid = bind.uid;
}
// acc
) { } binds;
groups.${user}.gid = uid;
};
system.activationScripts.createMediaServerDirs = ''
mkdir -p ${hostDataDir}/data
mkdir -p ${hostDataDir}/backups
chown -R ${toString uid}:${toString uid} ${hostDataDir}
chmod -R 750 ${hostDataDir}
'';
containers.${name} = {
ephemeral = true;
autoStart = true;
privateNetwork = true;
inherit localAddress hostAddress;
bindMounts = lib.foldl (
acc: bind:
{
"${bind.container}" = {
hostPath = bind.host;
privateNetwork = false;
bindMounts = {
"/var/lib/vaultwarden" = {
hostPath = "${hostDataDir}/data";
isReadOnly = false;
};
}
// acc
) { } binds;
"/var/lib/backups/vaultwarden" = {
hostPath = "${hostDataDir}/backups";
isReadOnly = false;
};
};
config =
{ ... }:
{
system.stateVersion = "24.11";
users = lib.foldl (
acc: bind:
{
users.${bind.user} = {
users = {
users.${user} = {
isSystemUser = true;
home = bind.container;
uid = bind.uid;
group = bind.user;
group = user;
inherit uid;
};
groups.${user}.gid = uid;
};
groups.${bind.user}.gid = bind.uid;
}
// acc
) { } binds;
services.vaultwarden = {
enable = true;
dbBackend = "sqlite";
backupDir = "/data/backups";
backupDir = "/var/lib/backups/vaultwarden";
config = {
DOMAIN = "https://vault.joshuabell.xyz";
SIGNUPS_ALLOWED = false;
ROCKET_PORT = builtins.toString v_port;
ROCKET_ADDRESS = "127.0.0.1";
# ADMIN_TOKEN = "$argon2id$v=19$m=65540,t=3,p=4$2DU5GEIKJeMoxqHrAacAYpX4BsSbOgoRmM2+4wjbAvY$9ZyWVV4xIx4M7/WGfvznOhEvrVx+4DrHcBPmeKKUMYE";
};
};
networking.firewall = {
enable = true;
allowedTCPPorts = [ 8222 ];
};
};
};
@ -89,7 +73,7 @@ in
locations = {
"/" = {
proxyWebsockets = true;
proxyPass = "http://${localAddress}:8222"; # vaultwarden TODO left off here the port is 8000 depsite the docs showing 8222 as default, set ecplisit
proxyPass = "http://127.0.0.1:${builtins.toString v_port}";
};
};
};