1 { config, lib, pkgs, ... }:
3 cfg = config.services.dante;
4 confFile = pkgs.writeText "dante-sockd.conf" ''
6 user.unprivileged: dante
15 maintainers = with lib.maintainers; [ arobyn ];
20 enable = lib.mkEnableOption "Dante SOCKS proxy";
22 config = lib.mkOption {
23 type = lib.types.lines;
25 Contents of Dante's configuration file.
26 NOTE: user.privileged, user.unprivileged and logoutput are set by the service.
32 config = lib.mkIf cfg.enable {
34 { assertion = cfg.config != "";
35 message = "please provide Dante configuration file contents";
40 description = "Dante SOCKS proxy daemon user";
44 users.groups.dante = {};
46 systemd.services.dante = {
47 description = "Dante SOCKS v4 and v5 compatible proxy server";
48 wants = [ "network-online.target" ];
49 after = [ "network-online.target" ];
50 wantedBy = [ "multi-user.target" ];
54 ExecStart = "${pkgs.dante}/bin/sockd -f ${confFile}";
55 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
56 # Can crash sometimes; see https://github.com/NixOS/nixpkgs/pull/39005#issuecomment-381828708
57 Restart = "on-failure";