about summary refs log tree commit diff
path: root/profiles/samba.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-05-10 19:57:20 -0700
committerFranck Cuny <franck@fcuny.net>2023-05-10 19:57:20 -0700
commit0bece1c755a7869bf0d5194ae37da3113856a2f6 (patch)
treea2d098744d265d1d9ca2cd34c9a01c6f5d7d58a1 /profiles/samba.nix
parenthosts/tahoe: move avahi configuration here (diff)
downloadworld-0bece1c755a7869bf0d5194ae37da3113856a2f6.tar.gz
profiles/samba: convert the old module as a profile
Diffstat (limited to '')
-rw-r--r--profiles/samba.nix33
1 files changed, 33 insertions, 0 deletions
diff --git a/profiles/samba.nix b/profiles/samba.nix
new file mode 100644
index 0000000..d1f186b
--- /dev/null
+++ b/profiles/samba.nix
@@ -0,0 +1,33 @@
+{ config, pkgs, lib, ... }:
+let
+  makePublicShare = path: {
+    name = builtins.baseNameOf path;
+    value = {
+      inherit path;
+      browseable = "yes";
+      writeable = "no";
+      "guest ok" = "yes";
+      "guest only" = "yes";
+      "force user" = "nobody";
+    };
+  };
+  publicShares = [ "/data/fast/music" "/data/fast/videos" ];
+in
+{
+  # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/network-filesystems/samba.nix
+  services.samba = {
+    enable = true;
+    extraConfig = ''
+      workgroup = WORKGROUP
+      server string = tahoe
+      netbios name = tahoe
+      security = user
+      guest account = nobody
+      mangled names = no
+      client min protocol = SMB2
+      map to guest = bad user
+      ntlm auth = true
+    '';
+    shares = with lib; (listToAttrs (map makePublicShare cfg.publicShares));
+  };
+}