add core configuration
This commit is contained in:
parent
74c78e1c68
commit
f40517cff1
94 changed files with 2816 additions and 959 deletions
17
modules/fileshare/default.nix
Normal file
17
modules/fileshare/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{lib, ...}: let
|
||||
# recursively construct attr-set of a directory
|
||||
getDir = dir:
|
||||
lib.mapAttrs (file: type:
|
||||
if type == "directory"
|
||||
then getDir "${dir}/${file}"
|
||||
else type) (
|
||||
builtins.readDir dir
|
||||
);
|
||||
files = dir: lib.collect lib.isString (lib.mapAttrsRecursive (path: type: lib.concatStringsSep "/" path) (getDir dir));
|
||||
validFiles = dir:
|
||||
map (file: ./. + "/${file}") (
|
||||
lib.filter (file: lib.hasSuffix ".nix" file && file != "default.nix") (files dir)
|
||||
);
|
||||
in {
|
||||
imports = validFiles ./.;
|
||||
}
|
55
modules/fileshare/samba.nix
Normal file
55
modules/fileshare/samba.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.lily.fileshare;
|
||||
in {
|
||||
options.lily.fileshare.enable = lib.mkEnableOption "activate local filesharing";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.samba = {
|
||||
enable = true;
|
||||
securityType = "user"; #Keep user, but use guest account.
|
||||
openFirewall = true;
|
||||
settings = {
|
||||
global = {
|
||||
workgroup = "WORKGROUP"; #Ensure this matches your network's workgroup.
|
||||
"server string" = "smbnix";
|
||||
"netbios name" = "smbnix";
|
||||
"security" = "user"; #Keep this as user, but guest will be used for access.
|
||||
"hosts allow" = "192.168.1. 127.0.0.1 localhost"; #Adjust to your LAN.
|
||||
"hosts deny" = "0.0.0.0/0";
|
||||
"guest account" = "nobody"; #Important for guest access.
|
||||
"map to guest" = "bad user"; #Maps unknown users to guest.
|
||||
};
|
||||
"public" = {
|
||||
"path" = "/ext/share";
|
||||
"browseable" = "yes";
|
||||
"read only" = "no";
|
||||
"guest ok" = "yes"; #Allows guest access.
|
||||
"create mask" = "0644";
|
||||
"directory mask" = "0755";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.samba-wsdd = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
services.avahi = {
|
||||
enable = true;
|
||||
nssmdns = true;
|
||||
nssmdns4 = true;
|
||||
openFirewall = true;
|
||||
reflector = true;
|
||||
publish = {
|
||||
domain = true;
|
||||
enable = true;
|
||||
userServices = true;
|
||||
addresses = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue