grace/dots
dotfiles/nix configs
git clone https://git.gae.moe/grace/dots
b70d9f9
main
1{ config , pkgs , ...} : 2 3let 4host = import ../hosts.nix ; 5root = "/mnt/backup" ; 6nfs = " ${ root } /nfs" ; 7timemachine = " ${ root } /timemachine" ; 8uid = toString config . users . users .${ host . user }. uid ; 9gid = toString config . ids . gids . users ; 10exportOptions = [ 11"rw" 12"sync" 13"fsid=0" 14"all_squash" 15"anonuid= ${ uid } " 16"anongid= ${ gid } " 17"no_subtree_check" 18"insecure" 19]; 20in 21{ 22users . users .${ host . user }. openssh . authorizedKeys . keys = [ 23"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzErojBe08D6vMxI+LJXOx7bM+RJF7ZFrCopagpYNm6 root@knuth" 24]; 25 26services . nfs . server = { 27enable = true ; 28exports .${ nfs } = { 29"100.64.0.0/10" = exportOptions ; 30"fd7a:115c:a1e0::/48" = exportOptions ; 31}; 32}; 33services . nfs . settings . nfsd = { 34vers3 = false ; 35vers4 = true ; 36udp = false ; 37}; 38systemd . services . nfs-server = { 39unitConfig . RequiresMountsFor = [ root ]; 40}; 41 42systemd . services . backup-directories = { 43description = "Prepare backup shares on the mounted backup disk" ; 44requiredBy = [ 45"nfs-server.service" 46"nfs-mountd.service" 47"samba-smbd.service" 48]; 49before = [ 50"nfs-server.service" 51"nfs-mountd.service" 52"samba-smbd.service" 53]; 54unitConfig . RequiresMountsFor = [ root ]; 55serviceConfig = { 56Type = "oneshot" ; 57RemainAfterExit = true ; 58}; 59script = '' 60${ pkgs . coreutils } /bin/install -d -m 0700 -o ${ host . user } -g users ${ nfs } ${ timemachine } 61'' ; 62}; 63 64services . samba . settings = { 65global = { 66"vfs objects" = "catia fruit streams_xattr" ; 67"fruit:metadata" = "stream" ; 68"fruit:model" = "MacSamba" ; 69}; 70timemachine = { 71path = timemachine ; 72browseable = "yes" ; 73"read only" = "no" ; 74"guest ok" = "no" ; 75"valid users" = host . user ; 76"force user" = host . user ; 77"create mask" = "0600" ; 78"directory mask" = "0700" ; 79"fruit:time machine" = "yes" ; 80"hosts allow" = "100.64.0.0/10 fd7a:115c:a1e0::/48 127.0.0.1 ::1" ; 81"hosts deny" = "ALL" ; 82}; 83}; 84systemd . services . samba-smbd = { 85unitConfig . RequiresMountsFor = [ root ]; 86}; 87}