grace/dots

dotfiles/nix configs

git clone https://git.gae.moe/grace/dots

Grace Yoderi gotta stop doing these massive changesb70d9f9

main
2.1 KiB87 linesraw
1{ config, pkgs, ... }:
2
3let
4  host = import ../hosts.nix;
5  root = "/mnt/backup";
6  nfs = "${root}/nfs";
7  timemachine = "${root}/timemachine";
8  uid = toString config.users.users.${host.user}.uid;
9  gid = toString config.ids.gids.users;
10  exportOptions = [
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{
22  users.users.${host.user}.openssh.authorizedKeys.keys = [
23    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzErojBe08D6vMxI+LJXOx7bM+RJF7ZFrCopagpYNm6 root@knuth"
24  ];
25
26  services.nfs.server = {
27    enable = true;
28    exports.${nfs} = {
29      "100.64.0.0/10" = exportOptions;
30      "fd7a:115c:a1e0::/48" = exportOptions;
31    };
32  };
33  services.nfs.settings.nfsd = {
34    vers3 = false;
35    vers4 = true;
36    udp = false;
37  };
38  systemd.services.nfs-server = {
39    unitConfig.RequiresMountsFor = [ root ];
40  };
41
42  systemd.services.backup-directories = {
43    description = "Prepare backup shares on the mounted backup disk";
44    requiredBy = [
45      "nfs-server.service"
46      "nfs-mountd.service"
47      "samba-smbd.service"
48    ];
49    before = [
50      "nfs-server.service"
51      "nfs-mountd.service"
52      "samba-smbd.service"
53    ];
54    unitConfig.RequiresMountsFor = [ root ];
55    serviceConfig = {
56      Type = "oneshot";
57      RemainAfterExit = true;
58    };
59    script = ''
60      ${pkgs.coreutils}/bin/install -d -m 0700 -o ${host.user} -g users ${nfs} ${timemachine}
61    '';
62  };
63
64  services.samba.settings = {
65    global = {
66      "vfs objects" = "catia fruit streams_xattr";
67      "fruit:metadata" = "stream";
68      "fruit:model" = "MacSamba";
69    };
70    timemachine = {
71      path = timemachine;
72      browseable = "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  };
84  systemd.services.samba-smbd = {
85    unitConfig.RequiresMountsFor = [ root ];
86  };
87}