diff --git a/modules/smb.nix b/modules/smb.nix new file mode 100644 index 0000000..1321000 --- /dev/null +++ b/modules/smb.nix @@ -0,0 +1,30 @@ +{ config, pkgs, ... }: + +{ + services.samba = { + enable = true; + openFirewall = false; + shares = { + Media = { + browseable = "yes"; + "read only" = "no"; + "guest ok" = "no"; # Disables guest access, requires a user login + + # This is the key: any new file or directory created through the share + # will be assigned to the 'media_services' group. + "force group" = "media_services"; + + # Set permissions for new files/dirs to allow group write access. + "create mask" = "0660"; # File permissions: rw-rw---- + "directory mask" = "0770"; # Directory permissions: rwxrwx--- + }; + }; + }; + + # Enable network discovery service for clients. + services.samba-wsdd = { + enable = true; + openFirewall = false; + }; +} + diff --git a/nixos/homelab.nix b/nixos/homelab.nix index 1714823..778b8f8 100644 --- a/nixos/homelab.nix +++ b/nixos/homelab.nix @@ -15,9 +15,10 @@ # ../modules/home-assistant.nix # ../modules/home-assistant-vm.nix ../modules/vms/incus-base.nix - + ../modules/smb.nix ]; arrSuite.enable = true; + services.samba.shares.Media.path = "/media/storage/media" # nixpkgs.config.allowUnfree = true; boot.loader.systemd-boot.enable = true; # Or grub, as appropriate for your server boot.loader.efi.canTouchEfiVariables = true; @@ -284,7 +285,7 @@ wantedBy = [ "timers.target" ]; partOf = [ "kopia-backup.service" ]; # Links timer to the service timerConfig = { - OnCalendar = "daily"; # Or "hourly", "*-*-* 02:00:00" for 2 AM daily, etc. + OnCalendar = "hourly"; # Or "hourly", "*-*-* 02:00:00" for 2 AM daily, etc. Persistent = true; # Run on next boot if a scheduled run was missed Unit = "kopia-backup.service"; };