zerobin service : init

+103
+1
nixos/modules/module-list.nix
··· 401 ./services/networking/wicd.nix 402 ./services/networking/wpa_supplicant.nix 403 ./services/networking/xinetd.nix 404 ./services/networking/zerotierone.nix 405 ./services/networking/znc.nix 406 ./services/printing/cupsd.nix
··· 401 ./services/networking/wicd.nix 402 ./services/networking/wpa_supplicant.nix 403 ./services/networking/xinetd.nix 404 + ./services/networking/zerobin.nix 405 ./services/networking/zerotierone.nix 406 ./services/networking/znc.nix 407 ./services/printing/cupsd.nix
+102
nixos/modules/services/networking/zerobin.nix
···
··· 1 + { config, pkgs, lib, nodes, ... }: 2 + with lib; 3 + let 4 + cfg = config.services.zerobin; 5 + 6 + zerobin_config = pkgs.writeText "zerobin-config.py" '' 7 + PASTE_FILES_ROOT = "${cfg.dataDir}" 8 + ${cfg.extraConfig} 9 + ''; 10 + 11 + in 12 + { 13 + options = { 14 + services.zerobin = { 15 + enable = mkEnableOption "0bin"; 16 + 17 + dataDir = mkOption { 18 + type = types.str; 19 + default = "/var/lib/zerobin"; 20 + description = '' 21 + Path to the 0bin data directory 22 + ''; 23 + }; 24 + 25 + user = mkOption { 26 + type = types.str; 27 + default = "zerobin"; 28 + description = '' 29 + The user 0bin should run as 30 + ''; 31 + }; 32 + 33 + group = mkOption { 34 + type = types.str; 35 + default = "zerobin"; 36 + description = '' 37 + The group 0bin should run as 38 + ''; 39 + }; 40 + 41 + listenPort = mkOption { 42 + type = types.int; 43 + default = 8000; 44 + example = 1357; 45 + description = '' 46 + The port zerobin should listen on 47 + ''; 48 + }; 49 + 50 + listenAddress = mkOption { 51 + type = types.str; 52 + default = "localhost"; 53 + example = "127.0.0.1"; 54 + description = '' 55 + The address zerobin should listen to 56 + ''; 57 + }; 58 + 59 + extraConfig = mkOption { 60 + type = types.lines; 61 + default = ""; 62 + example = '' 63 + MENU = ( 64 + ('Home', '/'), 65 + ) 66 + COMPRESSED_STATIC_FILE = True 67 + ''; 68 + description = '' 69 + Extra configuration to be appended to the 0bin config file 70 + (see https://0bin.readthedocs.org/en/latest/en/options.html) 71 + ''; 72 + }; 73 + }; 74 + }; 75 + 76 + config = mkIf (cfg.enable) { 77 + users.users."${cfg.user}" = 78 + if cfg.user == "zerobin" then { 79 + isSystemUser = true; 80 + group = cfg.group; 81 + home = cfg.dataDir; 82 + createHome = true; 83 + } 84 + else {}; 85 + users.groups."${cfg.group}" = {}; 86 + 87 + systemd.services.zerobin = { 88 + enable = true; 89 + after = [ "network-interfaces.target" ]; 90 + wantedBy = [ "multi-user.target" ]; 91 + serviceConfig.ExecStart = "${pkgs.pythonPackages.zerobin}/bin/zerobin ${cfg.listenAddress} ${toString cfg.listenPort} false ${cfg.user} ${cfg.group} ${zerobin_config}"; 92 + serviceConfig.PrivateTmp="yes"; 93 + serviceConfig.User = cfg.user; 94 + serviceConfig.Group = cfg.group; 95 + preStart = '' 96 + mkdir -p ${cfg.dataDir} 97 + chown ${cfg.user} ${cfg.dataDir} 98 + ''; 99 + }; 100 + }; 101 + } 102 +