forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into staging-next
- Loading branch information
Showing
43 changed files
with
3,410 additions
and
733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
pkg = pkgs.haste-server; | ||
cfg = config.services.haste-server; | ||
|
||
format = pkgs.formats.json {}; | ||
in | ||
{ | ||
options.services.haste-server = { | ||
enable = mkEnableOption "haste-server"; | ||
openFirewall = mkEnableOption "firewall passthrough for haste-server"; | ||
|
||
settings = mkOption { | ||
description = '' | ||
Configuration for haste-server. | ||
For documentation see <link xlink:href="https://github.com/toptal/haste-server#settings">project readme</link> | ||
''; | ||
type = format.type; | ||
}; | ||
}; | ||
|
||
config = mkIf (cfg.enable) { | ||
networking.firewall.allowedTCPPorts = mkIf (cfg.openFirewall) [ cfg.settings.port ]; | ||
|
||
services.haste-server = { | ||
settings = { | ||
host = mkDefault "::"; | ||
port = mkDefault 7777; | ||
|
||
keyLength = mkDefault 10; | ||
maxLength = mkDefault 400000; | ||
|
||
staticMaxAge = mkDefault 86400; | ||
recompressStaticAssets = mkDefault false; | ||
|
||
logging = mkDefault [ | ||
{ | ||
level = "verbose"; | ||
type = "Console"; | ||
colorize = true; | ||
} | ||
]; | ||
|
||
keyGenerator = mkDefault { | ||
type = "phonetic"; | ||
}; | ||
|
||
rateLimits = { | ||
categories = { | ||
normal = { | ||
totalRequests = mkDefault 500; | ||
every = mkDefault 60000; | ||
}; | ||
}; | ||
}; | ||
|
||
storage = mkDefault { | ||
type = "file"; | ||
}; | ||
|
||
documents = { | ||
about = mkDefault "${pkg}/share/haste-server/about.md"; | ||
}; | ||
}; | ||
}; | ||
|
||
systemd.services.haste-server = { | ||
wantedBy = [ "multi-user.target" ]; | ||
requires = [ "network.target" ]; | ||
after = [ "network.target" ]; | ||
|
||
serviceConfig = { | ||
User = "haste-server"; | ||
DynamicUser = true; | ||
StateDirectory = "haste-server"; | ||
WorkingDirectory = "/var/lib/haste-server"; | ||
ExecStart = "${pkg}/bin/haste-server ${format.generate "config.json" cfg.settings}"; | ||
}; | ||
|
||
path = with pkgs; [ pkg coreutils ]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.