{ config, lib, pkgs, ... }: with lib; let cfg = config.services.uucp.media-server; touchStateFiles = name: '' touch ${cfg.queueDir}/${name}.queue touch ${cfg.queueDir}/${name}.space touch ${cfg.queueDir}/${name}.queuesize chown ${cfg.owner}:${cfg.group} ${cfg.queueDir}/${name}.queue ${cfg.queueDir}/${name}.space ${cfg.queueDir}/${name}.queuesize chmod 660 ${cfg.queueDir}/${name}.queue ${cfg.queueDir}/${name}.space ${cfg.queueDir}/${name}.queuesize ''; scripts = pkgs.callPackage ./uucp-mediaserver/scripts.nix { config = cfg; }; in { options = { services.uucp.media-server = { enable = mkEnableOption "UUCP media server"; remoteNodes = mkOption { type = types.listOf types.str; default = []; description = '' Clients to track ''; }; queueDir = mkOption { type = types.path; default = "/var/spool/media"; description = "Queue directory"; }; owner = mkOption { type = types.str; default = "root"; description = "Owner of the various queue files"; }; group = mkOption { type = types.str; default = "media"; description = "Group of the various queue files"; }; }; }; config = mkIf cfg.enable { system.activationScripts."uucp-media-server" = '' mkdir -p ${cfg.queueDir} chmod 750 ${cfg.queueDir} chown ${cfg.owner}:${cfg.group} ${cfg.queueDir} ${concatStringsSep "\n" (map touchStateFiles cfg.remoteNodes)} ''; environment.systemPackages = [ scripts ]; services.uucp.commandPath = [ "${scripts}/bin" ]; services.uucp.commands = genAttrs cfg.remoteNodes (name: ["mediaspace.${name}"] ); }; }