Add samba server

This commit is contained in:
Dmitriy 2019-09-16 15:01:09 +04:00
parent 937d877a66
commit d423af1b0a
4 changed files with 69 additions and 3 deletions

View File

@ -1,4 +1,4 @@
{ ... }: {
{ config, lib, ... }: {
imports = [
./applications/packages.nix
./applications/rofi.nix
@ -41,5 +41,6 @@
./network.nix
./wireguard.nix
./filesystems.nix
./samba.nix
];
}

View File

@ -6,10 +6,20 @@
else
[ "noatime" "compress=zstd" ];
};
"/shared" = lib.mkIf config.deviceSpecific.isVM {
"/shared/nixos" = lib.mkIf config.deviceSpecific.isVM {
fsType = "vboxsf";
device = "shared";
options = [ "rw" "nodev" "relatime" "iocharset=utf8" "uid=1000" "gid=100" "dmode=0770" "fmode=0770" "nofail" ];
options = [
"rw"
"nodev"
"relatime"
"nofail"
"dmode=0755"
"fmode=0644"
"uid=${toString config.users.users.alukard.uid}"
# "gid=${toString config.users.groups.users.gid}"
"gid=${toString config.users.groups.smbgrp.gid}"
];
};
};

54
modules/samba.nix Normal file
View File

@ -0,0 +1,54 @@
{ config, lib, pkgs, ... }: {
users.groups.smbgrp.gid = 2001;
# TODO: add nologin shell to this user
users.users.smbuser =
lib.mkIf (config.device == "AMD-Workstation" || config.device == "NixOS-VM") {
isNormalUser = false;
extraGroups = [
"smbgrp"
];
description = "User for samba sharing";
};
services.samba =
lib.mkIf (config.device == "AMD-Workstation" || config.device == "NixOS-VM") {
enable = true;
enableNmbd = false;
enableWinbindd = false;
invalidUsers = [ "root" ];
nsswins = false;
securityType = "user";
syncPasswordsByPam = false;
# shares = {
# };
# extraConfig = ''
configText = ''
[global]
server string = samba home server
server role = standalone server
disable netbios = yes
smb ports = 445
[private]
path = /shared/samba
browsable = yes
read only = no
force create mode = 0660
force directory mode = 2770
valid users = @smbgrp
[files]
path = /shared/files
browsable = yes
read only = no
guest only = yes
force create mode = 0660
force directory mode = 2770
force user = smbuser
'';
};
environment.systemPackages =
if (config.device == "AMD-Workstation" || config.device == "NixOS-VM") then
[ config.services.samba.package ]
else
[ ];
}

View File

@ -18,6 +18,7 @@
# "adbusers"
"input"
"vboxusers"
"smbgrp"
];
description = "Дмитрий Холкин";
uid = 1000;