Move samba server outside of modules

This commit is contained in:
Tyler Starr 2023-10-07 02:11:46 -07:00
parent 5a58d74799
commit b226a0c55d
4 changed files with 43 additions and 48 deletions

View File

@ -2,6 +2,7 @@
{
imports = [
./wireguard-server.nix
./samba-server.nix
../../modules
];
@ -128,7 +129,6 @@
tooling.enable = true;
};
services = {
samba-server.enable = true;
jellyfin.enable = true;
syncthing.enable = true;
};

View File

@ -0,0 +1,41 @@
{ config, lib, pkgs, ... }:
{
services.samba = {
enable = true;
extraConfig = ''
workgroup = WORKGROUP
server string = smbnix
netbios name = smbnix
security = user
hosts allow = 192.168.1. 127.0.0.1 localhost
hosts deny = 0.0.0.0/0
guest account = nobody
map to guest = bad user
'';
shares = {
private = {
"path" = "/engi";
browseable = "yes";
"read only" = "no";
"guest ok" = "no";
"force user" = "tstarr";
"force group" = "users";
};
public = {
"path" = "/engi";
browseable = "yes";
"read only" = "yes";
"guest ok" = "yes";
};
};
};
# Curiously, `services.samba` does not automatically open
# the needed ports in the firewall.
networking.firewall.allowedTCPPorts = [ 445 139 ];
networking.firewall.allowedUDPPorts = [ 137 138 ];
# To make SMB mounting easier on the command line
environment.systemPackages = with pkgs; [ cifs-utils ];
}

View File

@ -1,4 +1,4 @@
{ ... }:
{
imports = [ ./syncthing.nix ./samba-server.nix ./samba-client.nix ./jellyfin.nix ./virt-manager.nix ./peripherals.nix ];
imports = [ ./syncthing.nix ./samba-client.nix ./jellyfin.nix ./virt-manager.nix ./peripherals.nix ];
}

View File

@ -1,46 +0,0 @@
{ config, lib, pkgs, ... }:
let cfg = config.modules.services.samba-server;
in {
options.modules.services.samba-server.enable = lib.mkEnableOption "samba-server";
config = lib.mkIf cfg.enable {
services.samba = {
enable = true;
extraConfig = ''
workgroup = WORKGROUP
server string = smbnix
netbios name = smbnix
security = user
hosts allow = 192.168.1. 127.0.0.1 localhost
hosts deny = 0.0.0.0/0
guest account = nobody
map to guest = bad user
'';
shares = {
private = {
"path" = "/engi";
browseable = "yes";
"read only" = "no";
"guest ok" = "no";
"force user" = "tstarr";
"force group" = "users";
};
public = {
"path" = "/engi";
browseable = "yes";
"read only" = "yes";
"guest ok" = "yes";
};
};
};
# Curiously, `services.samba` does not automatically open
# the needed ports in the firewall.
networking.firewall.allowedTCPPorts = [ 445 139 ];
networking.firewall.allowedUDPPorts = [ 137 138 ];
# To make SMB mounting easier on the command line
environment.systemPackages = with pkgs; [ cifs-utils ];
};
}