diff options
-rw-r--r-- | flakes/fiche/flake.nix | 53 | ||||
-rw-r--r-- | modules/default.nix | 2 | ||||
-rw-r--r-- | modules/webapps/fiche.nix | 53 |
3 files changed, 54 insertions, 54 deletions
diff --git a/flakes/fiche/flake.nix b/flakes/fiche/flake.nix new file mode 100644 index 0000000..16055e8 --- /dev/null +++ b/flakes/fiche/flake.nix | |||
@@ -0,0 +1,53 @@ | |||
1 | { | ||
2 | description = "Command line pastebin for sharing terminal output"; | ||
3 | |||
4 | outputs = { self }: { | ||
5 | nixosModule = { config, lib, pkgs, ... }: { | ||
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 = | ||
25 | let cfg = config.services.fiche; | ||
26 | in lib.mkIf cfg.enable { | ||
27 | networking.firewall.allowedTCPPorts = [ cfg.port ]; | ||
28 | |||
29 | systemd.services.fiche = { | ||
30 | description = "Fiche server"; | ||
31 | wantedBy = [ "multi-user.target" ]; | ||
32 | after = [ "network.target" ]; | ||
33 | |||
34 | script = '' | ||
35 | exec ${pkgs.fiche}/bin/fiche -o ${cfg.dataDir} -d ${cfg.domain} ${lib.optionalString cfg.https "-S "} -p ${builtins.toString cfg.port} | ||
36 | ''; | ||
37 | |||
38 | serviceConfig = { | ||
39 | ExecStartPre = [ | ||
40 | "+${pkgs.coreutils}/bin/install -m 0755 -o fiche -d ${cfg.dataDir}" | ||
41 | ]; | ||
42 | DynamicUser = true; | ||
43 | User = "fiche"; | ||
44 | PrivateTmp = true; | ||
45 | Restart = "always"; | ||
46 | WorkingDirectory = cfg.dataDir; | ||
47 | ReadWritePaths = cfg.dataDir; | ||
48 | }; | ||
49 | }; | ||
50 | }; | ||
51 | }; | ||
52 | }; | ||
53 | } | ||
diff --git a/modules/default.nix b/modules/default.nix index cb2e7d9..2f06eb1 100644 --- a/modules/default.nix +++ b/modules/default.nix | |||
@@ -13,7 +13,7 @@ in | |||
13 | mastodon = ./webapps/mastodon.nix; | 13 | mastodon = ./webapps/mastodon.nix; |
14 | mediagoblin = ./webapps/mediagoblin.nix; | 14 | mediagoblin = ./webapps/mediagoblin.nix; |
15 | peertube = (flakeCompat ../flakes/peertube).nixosModule; | 15 | peertube = (flakeCompat ../flakes/peertube).nixosModule; |
16 | fiche = ./webapps/fiche.nix; | 16 | fiche = flakeLib.withNarKeyCompat flakeCompat ../flakes/fiche "nixosModule"; |
17 | paste = flakeLib.withNarKeyCompat flakeCompat ../flakes/paste "nixosModule"; | 17 | paste = flakeLib.withNarKeyCompat flakeCompat ../flakes/paste "nixosModule"; |
18 | 18 | ||
19 | opendmarc = flakeLib.withNarKeyCompat flakeCompat ../flakes/opendmarc "nixosModule"; | 19 | opendmarc = flakeLib.withNarKeyCompat flakeCompat ../flakes/opendmarc "nixosModule"; |
diff --git a/modules/webapps/fiche.nix b/modules/webapps/fiche.nix deleted file mode 100644 index 9061b2e..0000000 --- a/modules/webapps/fiche.nix +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | { lib, pkgs, config, ... }: | ||
2 | let | ||
3 | cfg = config.services.fiche; | ||
4 | in | ||
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 | } | ||