git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #92378 from jnetod/zfs-smb-share-fix

zfs: patch client path used in smb share

commit7c2d15627a3012c5e5af1d1664a53599687cf1d1 authorJörg Thalheim <Mic92@users.noreply.github.com> dateMon 21 Jun 2021, 07:11 (5 years ago) parent57ac553a4cb90b
2 files changed+26−2
nixos/tests/zfs.nix+24−1 pkgs/os-specific/linux/zfs/default.nix+2−1
nixos/tests/zfs.nix+24−1
@@ -18,13 +18,29 @@ let
1818 maintainers = [ adisbladis ];
1919 };
2020
21− machine = { pkgs, lib, ... }: {
21+ machine = { pkgs, lib, ... }:
22+ let
23+ usersharePath = "/var/lib/samba/usershares";
24+ in {
2225 virtualisation.emptyDiskImages = [ 4096 ];
2326 networking.hostId = "deadbeef";
2427 boot.kernelPackages = kernelPackage;
2528 boot.supportedFilesystems = [ "zfs" ];
2629 boot.zfs.enableUnstable = enableUnstable;
2730
31+ services.samba = {
32+ enable = true;
33+ extraConfig = ''
34+ registry shares = yes
35+ usershare path = ${usersharePath}
36+ usershare allow guests = yes
37+ usershare max shares = 100
38+ usershare owner only = no
39+ '';
40+ };
41+ systemd.services.samba-smbd.serviceConfig.ExecStartPre =
42+ "${pkgs.coreutils}/bin/mkdir -m +t -p ${usersharePath}";
43+
2844 environment.systemPackages = [ pkgs.parted ];
2945
3046 # Setup regular fileSystems machinery to ensure forceImportAll can be
@@ -58,8 +74,15 @@ let
5874 "udevadm settle",
5975 "zpool create rpool /dev/vdb1",
6076 "zfs create -o mountpoint=legacy rpool/root",
77+ # shared datasets cannot have legacy mountpoint
78+ "zfs create rpool/shared_smb",
6179 "mount -t zfs rpool/root /tmp/mnt",
6280 "udevadm settle",
81+ # wait for samba services
82+ "systemctl is-system-running --wait",
83+ "zfs set sharesmb=on rpool/shared_smb",
84+ "zfs share rpool/shared_smb",
85+ "smbclient -gNL localhost | grep rpool_shared_smb",
6386 "umount /tmp/mnt",
6487 "zpool destroy rpool",
6588 "udevadm settle",
pkgs/os-specific/linux/zfs/default.nix+2−1
@@ -6,7 +6,7 @@
66# Userspace dependencies
77, zlib, libuuid, python3, attr, openssl
88, libtirpc
9−, nfs-utils
9+, nfs-utils, samba
1010, gawk, gnugrep, gnused, systemd
1111, smartmontools, enableMail ? false
1212, sysstat, pkg-config
@@ -55,6 +55,7 @@ let
5555 # And if it's enabled by default, only change that if we explicitly disable python to remove python from the closure
5656 nfs-utils.override (old: { enablePython = old.enablePython or true && enablePython; })
5757 }/bin/exportfs"
58+ substituteInPlace ./lib/libshare/smb.h --replace "/usr/bin/net" "${samba}/bin/net"
5859 substituteInPlace ./config/user-systemd.m4 --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
5960 substituteInPlace ./config/zfs-build.m4 --replace "\$sysconfdir/init.d" "$out/etc/init.d" \
6061 --replace "/etc/default" "$out/etc/default"