1 { config, lib, pkgs, ... }:
6 pkg = pkgs.haste-server;
7 cfg = config.services.haste-server;
9 format = pkgs.formats.json {};
12 options.services.haste-server = {
13 enable = mkEnableOption (lib.mdDoc "haste-server");
14 openFirewall = mkEnableOption (lib.mdDoc "firewall passthrough for haste-server");
17 description = lib.mdDoc ''
18 Configuration for haste-server.
19 For documentation see [project readme](https://github.com/toptal/haste-server#settings)
25 config = mkIf (cfg.enable) {
26 networking.firewall.allowedTCPPorts = mkIf (cfg.openFirewall) [ cfg.settings.port ];
28 services.haste-server = {
30 host = mkDefault "::";
31 port = mkDefault 7777;
33 keyLength = mkDefault 10;
34 maxLength = mkDefault 400000;
36 staticMaxAge = mkDefault 86400;
37 recompressStaticAssets = mkDefault false;
47 keyGenerator = mkDefault {
54 totalRequests = mkDefault 500;
55 every = mkDefault 60000;
65 about = mkDefault "${pkg}/share/haste-server/about.md";
70 systemd.services.haste-server = {
71 wantedBy = [ "multi-user.target" ];
72 requires = [ "network.target" ];
73 after = [ "network.target" ];
76 User = "haste-server";
78 StateDirectory = "haste-server";
79 WorkingDirectory = "/var/lib/haste-server";
80 ExecStart = "${pkg}/bin/haste-server ${format.generate "config.json" cfg.settings}";
83 path = with pkgs; [ pkg coreutils ];