|
| 1 | +{ lib, pkgs, config, options, |
| 2 | + specialArgs, modulesPath, |
| 3 | +}: |
| 4 | +let |
| 5 | + cfg = config.services.pyhesiodfs; |
| 6 | + athena-pkgs = import ../pkgs { inherit pkgs; }; |
| 7 | +in |
| 8 | +{ |
| 9 | + options.services.pyhesiodfs = (let |
| 10 | + mkOption = lib.mkOption; |
| 11 | + mkEnableOption = lib.mkEnableOption; |
| 12 | + types = lib.types; |
| 13 | + in { |
| 14 | + enable = mkEnableOption "pyhesiodfs"; |
| 15 | + }); |
| 16 | + |
| 17 | + config = lib.mkIf cfg.enable { |
| 18 | + users.groups.pyhesiodfs = { }; |
| 19 | + users.users.pyhesiodfs = { |
| 20 | + description = "pyhesiodfs /mit/ automounter"; |
| 21 | + isSystemUser = true; |
| 22 | + group = "pyhesiodfs"; |
| 23 | + }; |
| 24 | + programs.fuse.userAllowOther = true; |
| 25 | + |
| 26 | + # systemd unit |
| 27 | + systemd.services."pyhesiodfs" = { |
| 28 | + # https://github.com/mit-athena/pyhesiodfs/blob/debian/debian/debathena-pyhesiodfs.service |
| 29 | + description = "Hesiod automounter for Athena lockers"; |
| 30 | + after = [ "local-fs.target" "network.target" "systemd-tmpfiles-setup.service" ]; |
| 31 | + before = [ "remote-fs.target" ]; |
| 32 | + #documentation = [ ]; |
| 33 | + serviceConfig = { |
| 34 | + Type = "simple"; |
| 35 | + Environment = "pyhesiodfs_dir=/mit"; |
| 36 | + OOMScoreAdjust = -1000; |
| 37 | + User = "pyhesiodfs"; |
| 38 | + ExecStart = "${athena-pkgs.pyhesiodfs}/bin/pyhesiodfs -f $pyhesiodfs_dir -o nonempty"; |
| 39 | + }; |
| 40 | + wantedBy= [ "multi-user.target" "remote-fs.target" ]; |
| 41 | + }; |
| 42 | + |
| 43 | + # Create /mit/ |
| 44 | + systemd.tmpfiles.rules = [ |
| 45 | + # https://github.com/mit-athena/pyhesiodfs/blob/debian/debian/debathena-pyhesiodfs.tmpfile |
| 46 | + "d /mit 0770 root pyhesiodfs" |
| 47 | + ]; |
| 48 | + }; |
| 49 | +} |
0 commit comments