1 { config, lib, pkgs, ... }:
3 pkg = pkgs.haste-server;
4 cfg = config.services.haste-server;
6 format = pkgs.formats.json {};
9 options.services.haste-server = {
10 enable = lib.mkEnableOption "haste-server";
11 openFirewall = lib.mkEnableOption "firewall passthrough for haste-server";
13 settings = lib.mkOption {
15 Configuration for haste-server.
16 For documentation see [project readme](https://github.com/toptal/haste-server#settings)
22 config = lib.mkIf (cfg.enable) {
23 networking.firewall.allowedTCPPorts = lib.mkIf (cfg.openFirewall) [ cfg.settings.port ];
25 services.haste-server = {
27 host = lib.mkDefault "::";
28 port = lib.mkDefault 7777;
30 keyLength = lib.mkDefault 10;
31 maxLength = lib.mkDefault 400000;
33 staticMaxAge = lib.mkDefault 86400;
34 recompressStaticAssets = lib.mkDefault false;
36 logging = lib.mkDefault [
44 keyGenerator = lib.mkDefault {
51 totalRequests = lib.mkDefault 500;
52 every = lib.mkDefault 60000;
57 storage = lib.mkDefault {
62 about = lib.mkDefault "${pkg}/share/haste-server/about.md";
67 systemd.services.haste-server = {
68 wantedBy = [ "multi-user.target" ];
69 requires = [ "network.target" ];
70 after = [ "network.target" ];
73 User = "haste-server";
75 StateDirectory = "haste-server";
76 WorkingDirectory = "/var/lib/haste-server";
77 ExecStart = "${pkg}/bin/haste-server ${format.generate "config.json" cfg.settings}";
80 path = with pkgs; [ pkg coreutils ];