diff options
author | Ethel Morgan <eth@ethulhu.co.uk> | 2020-06-02 11:53:53 +0100 |
---|---|---|
committer | Ethel Morgan <eth@ethulhu.co.uk> | 2020-06-02 11:54:19 +0100 |
commit | 9c329e837211c0d26ead9765d0815ba08db9bd8f (patch) | |
tree | 1363baa2e64d4939137882f02c833659b1de2b24 /nixos/modules/services/helix-directory.nix | |
parent | 3341f42557f6b5e19c3cfd3e1eef43c5a4c2745e (diff) |
update Helix version, add service for helix-directory
Diffstat (limited to 'nixos/modules/services/helix-directory.nix')
-rw-r--r-- | nixos/modules/services/helix-directory.nix | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/nixos/modules/services/helix-directory.nix b/nixos/modules/services/helix-directory.nix new file mode 100644 index 0000000..4601dea --- /dev/null +++ b/nixos/modules/services/helix-directory.nix @@ -0,0 +1,57 @@ +{ config, lib, pkgs, ... }: +with lib; + +let + cfg = config.eth.services.helix-directory; + +in { + + options.eth.services.helix-directory = { + + enable = mkEnableOption "Whether to enable helix-directory"; + + friendlyName = mkOption { + type = types.str; + default = "Helix (${config.networking.hostName})"; + description = "Human-readable name to broadcast"; + example = "My Media Server"; + }; + + directory = mkOption { + type = types.str; + default = ""; + description = "Directory to serve"; + example = "/mnt/md0/media"; + }; + }; + + + config = mkIf cfg.enable { + assertions = [ + { + assertion = cfg.directory != ""; + message = "must set config.eth.services.helix-directory.directory"; + } + ]; + + systemd.services.helix-directory = { + enable = true; + description = "Helix UPnP ContentDirectory server"; + wants = [ "network.target" ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + DynamicUser = true; + + ExecStart = "${pkgs.eth.helix}/bin/helix-directory -friendly-name ${escapeShellArg cfg.friendlyName} -path ${escapeShellArg cfg.directory}"; + + NoNewPrivileges = true; + ProtectHome = true; + ProtectKernelTunables = true; + ProtectControlGroups = true; + ProtectKernelModules = true; + }; + }; + }; + +} |