Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hosts/glyph/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
device = "zdata/backup";
fsType = "zfs";
};
fileSystems."/mnt/documents" = {
device = "zdata/documents";
fsType = "zfs";
};

users.users.colleen = {
isSystemUser = true;
group = "users";
description = "Partner's Samba user";
};

networking.hostName = "glyph";
networking.hostId = "e7bdc076"; # Ensure correct ZFS pool imported
Expand Down
1 change: 1 addition & 0 deletions hosts/glyph/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
./open-webui.nix
./prometheus.nix
./samba.nix
./webdav.nix
./torrents.nix
./windmill.nix
];
Expand Down
5 changes: 4 additions & 1 deletion hosts/glyph/services/samba.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
shares = {
Archive = mkShare "/mnt/archive" "mu" "users";
Backup = mkShare "/mnt/backup" "mu" "users" // {"fruit:time machine" = "yes";};
Documents = mkShare "/mnt/documents" "colleen" "users";
Media = mkShare "/mnt/media" config.services.jellyfin.user config.services.jellyfin.group;
Notes = mkShare "/var/lib/basic-memory/basic-memory" "basic-memory" "basic-memory";
Torrents = mkShare "/mnt/torrents" config.services.transmission.user config.services.transmission.group;
Expand All @@ -33,7 +34,7 @@
{
global = {
"invalid users" = [];
securityType = "user";
security = "user";
"vfs objects" = "catia fruit streams_xattr";
"fruit:metadata" = "stream";
"fruit:resource" = "file";
Expand Down Expand Up @@ -65,11 +66,13 @@
Type = "oneshot";
ExecStart = let
defaultUsrGrp = "mu:users";
colleenUsrGrp = "colleen:users";
jellyfinUsrGrp = with config.services.jellyfin; "${user}:${group}";
transmissionUsrGrp = with config.services.transmission; "${user}:${group}";
in [
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} archive"
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} backup"
"${pkgs.coreutils}/bin/chown -R ${colleenUsrGrp} documents"
# N.B.: /mnt/media/Music is used by Roon, not Jellyfin
"${pkgs.coreutils}/bin/chown -R ${jellyfinUsrGrp} media/Movies media/TV media/Unsorted media/Video"
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} media/Music"
Expand Down
35 changes: 35 additions & 0 deletions hosts/glyph/services/webdav.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{lib, ...}: {
services.httpd = {
enable = true;
adminAddr = "admin@localhost";
extraModules = ["dav" "dav_fs" "dav_lock"];
virtualHosts."docs.zx.dev" = {
listen = [
{
ip = "*";
port = 8185;
}
];
documentRoot = "/mnt/documents";
extraConfig = ''
DavLockDB /var/lib/httpd/DavLockDB

<Directory "/mnt/documents">
DAV On
Options Indexes
AllowOverride None
Require all granted
</Directory>
'';
};
};

users.users.wwwrun.extraGroups = ["users"];

systemd.services.httpd.serviceConfig.ReadWritePaths = ["/mnt/documents"];

systemd.tmpfiles.rules = [
"d /mnt/documents 2775 colleen users -"
"d /var/lib/httpd 0755 wwwrun wwwrun -"
];
}
Binary file added hosts/spore/secrets/docs-htpasswd.age
Binary file not shown.
27 changes: 27 additions & 0 deletions hosts/spore/services/web/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
];

age.secrets.cloudflare-dns.file = ../../secrets/cloudflare-dns.age;
age.secrets.docs-htpasswd = {
file = ../../secrets/docs-htpasswd.age;
owner = "nginx";
mode = "400";
};

services.nginx = {
enable = true;
Expand Down Expand Up @@ -126,6 +131,28 @@
useACMEHost = "zx.dev";
locations."/".proxyPass = "http://glyph.note-iwato.ts.net:8096";
};
"docs.zx.dev" = {
forceSSL = true;
useACMEHost = "zx.dev";
locations."/" = {
proxyPass = "http://glyph.note-iwato.ts.net:8185";
extraConfig = ''
auth_basic "Documents";
auth_basic_user_file ${config.age.secrets.docs-htpasswd.path};
proxy_set_header Authorization "";
client_max_body_size 0;
proxy_request_buffering off;

# Rewrite WebDAV Destination header for MOVE/COPY: Finder sends
# https://docs.zx.dev/... but Apache sees itself as http://docs.zx.dev:8185.
set $dav_dest $http_destination;
if ($dav_dest ~ "^https://docs\.zx\.dev(/.*)$") {
set $dav_dest http://docs.zx.dev:8185$1;
}
proxy_set_header Destination $dav_dest;
'';
};
};
"music.zx.dev" = {
forceSSL = true;
useACMEHost = "zx.dev";
Expand Down
1 change: 1 addition & 0 deletions lib/secrets/spore.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let
keys = with (import ../keys.nix); [spore Rhizome];
in {
"hosts/spore/secrets/cloudflare-dns.age".publicKeys = keys;
"hosts/spore/secrets/docs-htpasswd.age".publicKeys = keys;
"hosts/spore/secrets/homepage-env.age".publicKeys = keys;
"hosts/spore/secrets/grafana-client-secret.age".publicKeys = keys;
"hosts/spore/secrets/grafana-secret-key.age".publicKeys = keys;
Expand Down
Loading