nixfiles/services/geesefs.nix

58 lines
1.4 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
{
options.services.geesefs = with lib; {
enable = mkEnableOption "geesefs";
package = mkOption {
type = types.package;
default = pkgs.geesefs;
defaultText = "pkgs.geesefs";
description = "geesefs package";
};
serviceName = mkOption {
type = types.str;
default = "geesefs";
description = "geesefs service name";
};
args = mkOption {
type = types.listOf types.str;
default = [ ];
description = "geesefs arguments";
};
bucket = mkOption {
type = types.str;
description = "geesefs bucket name";
};
mountPoint = mkOption {
type = types.str;
description = "geesefs mount point";
};
};
config = let
cfg = config.services.geesefs;
allArgs = cfg.args ++ [
"-f" # foreground
cfg.bucket
cfg.mountPoint
];
in {
systemd.services.${cfg.serviceName} = {
description = "${cfg.serviceName} Daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.fuse ];
serviceConfig = {
User = "root";
Group = "root";
ExecStart = "${cfg.package}/bin/geesefs ${builtins.concatStringsSep " " (map lib.escapeShellArg allArgs)}";
Restart = "on-failure";
};
};
systemd.tmpfiles.rules = [
"d ${cfg.mountPoint} 0777 root root -"
];
};
}