summaryrefslogtreecommitdiff
path: root/modules/webapps/fiche.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-11 17:25:48 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-25 00:04:56 +0200
commitdb85e40f318ce354b3a431ec46d573316d88afee (patch)
treed9f1b0d87f8923c549d154c5de4652a32ebc50b4 /modules/webapps/fiche.nix
parent7315af9f9babd5942cd685f04fff347b996fb522 (diff)
downloadNUR-db85e40f318ce354b3a431ec46d573316d88afee.tar.gz
NUR-db85e40f318ce354b3a431ec46d573316d88afee.tar.zst
NUR-db85e40f318ce354b3a431ec46d573316d88afee.zip
Add fiche module (a program to submit paste from command line)
Diffstat (limited to 'modules/webapps/fiche.nix')
-rw-r--r--modules/webapps/fiche.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/webapps/fiche.nix b/modules/webapps/fiche.nix
new file mode 100644
index 00000000..9061b2ea
--- /dev/null
+++ b/modules/webapps/fiche.nix
@@ -0,0 +1,53 @@
1{ lib, pkgs, config, ... }:
2let
3 cfg = config.services.fiche;
4in
5{
6 options.services.fiche = {
7 enable = lib.mkEnableOption "Enable fiche’s service";
8 port = lib.mkOption {
9 type = lib.types.port;
10 description = "Port to listen to";
11 };
12 domain = lib.mkOption {
13 type = lib.types.str;
14 description = "Domain";
15 };
16 dataDir = lib.mkOption {
17 type = lib.types.path;
18 default = "/var/lib/fiche";
19 description = "Directory where to place the pastes";
20 };
21 https = lib.mkEnableOption "Use https";
22 };
23
24 config = lib.mkIf cfg.enable {
25 networking.firewall.allowedTCPPorts = [ cfg.port ];
26
27
28 system.activationScripts.fiche = ''
29 mkdir -p /var/lib/fiche
30 '';
31 systemd.services.fiche = {
32 description = "Fiche server";
33 wantedBy = [ "multi-user.target" ];
34 after = [ "network.target" ];
35
36 script = ''
37 exec ${pkgs.fiche}/bin/fiche -o ${cfg.dataDir} -d ${cfg.domain} ${lib.optionalString cfg.https "-S "} -p ${builtins.toString cfg.port}
38 '';
39
40 serviceConfig = {
41 ExecStartPre = [
42 "+${pkgs.coreutils}/bin/install -m 0755 -o fiche -d /var/lib/fiche"
43 ];
44 DynamicUser = true;
45 User = "fiche";
46 PrivateTmp = true;
47 Restart = "always";
48 WorkingDirectory = cfg.dataDir;
49 ReadWritePaths = cfg.dataDir;
50 };
51 };
52 };
53}