jakstpub: open up http

This commit is contained in:
Motiejus Jakštys 2023-09-17 22:12:46 +03:00
parent a3e8903669
commit f38fd993d3
2 changed files with 81 additions and 68 deletions

View File

@ -4,7 +4,10 @@
pkgs, pkgs,
myData, myData,
... ...
}: { }: let
cfg = config.mj.services.jakstpub;
subnets = myData.subnets;
in {
options.mj.services.jakstpub = with lib.types; { options.mj.services.jakstpub = with lib.types; {
enable = lib.mkEnableOption "Enable jakstpub"; enable = lib.mkEnableOption "Enable jakstpub";
dataDir = lib.mkOption {type = path;}; dataDir = lib.mkOption {type = path;};
@ -14,8 +17,17 @@
hostname = lib.mkOption {type = str;}; hostname = lib.mkOption {type = str;};
}; };
config = with config.mj.services.jakstpub; config = lib.mkIf cfg.enable {
lib.mkIf enable { services.caddy = {
enable = true;
virtualHosts.":80".extraConfig = ''
root * ${cfg.dataDir}
@denied not remote_ip ${subnets.vno1.cidr} ${subnets.vno3.cidr} ${subnets.tailscale.cidr}
file_server browse {}
encode gzip
'';
};
services.samba = { services.samba = {
# https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server # https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Standalone_Server
enable = true; enable = true;
@ -29,7 +41,7 @@
''; '';
shares = { shares = {
public = { public = {
path = dataDir; path = cfg.dataDir;
writeable = "yes"; writeable = "yes";
public = "yes"; public = "yes";
"guest ok" = "yes"; "guest ok" = "yes";
@ -44,7 +56,7 @@
services.samba-wsdd = { services.samba-wsdd = {
enable = true; enable = true;
hostname = hostname; hostname = cfg.hostname;
}; };
users.users.jakstpub = { users.users.jakstpub = {
@ -54,19 +66,20 @@
group = "jakstpub"; group = "jakstpub";
isSystemUser = true; isSystemUser = true;
createHome = false; createHome = false;
uid = uidgid; uid = cfg.uidgid;
}; };
users.groups.jakstpub.gid = uidgid; users.groups.jakstpub.gid = cfg.uidgid;
systemd.services.samba-smbd = { systemd.services.samba-smbd = {
unitConfig.Requires = requires; unitConfig.Requires = cfg.requires;
}; };
mj.services.friendlyport.ports = [ mj.services.friendlyport.ports = [
{ {
subnets = with myData.subnets; [tailscale.cidr vno1.cidr vno3.cidr]; subnets = with myData.subnets; [tailscale.cidr vno1.cidr vno3.cidr];
tcp = [ tcp = [
80 # caddy above
139 # smbd 139 # smbd
445 # smbd 445 # smbd
5357 # wsdd 5357 # wsdd