diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-10-16 15:56:32 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-10-16 20:22:12 +0200 |
commit | 668ba4d439d3b60ade9f96fd158ed293ff211f60 (patch) | |
tree | ad1e274cff226a4319e2c91f50fdbf7cdf678f25 /flakes | |
parent | 4c4652aabf2cb3ac8b40f2856eca07a1df9c27e0 (diff) | |
download | Nix-668ba4d439d3b60ade9f96fd158ed293ff211f60.tar.gz Nix-668ba4d439d3b60ade9f96fd158ed293ff211f60.tar.zst Nix-668ba4d439d3b60ade9f96fd158ed293ff211f60.zip |
Move Fiche to flakes
Diffstat (limited to 'flakes')
-rw-r--r-- | flakes/fiche/flake.nix | 53 |
1 files changed, 53 insertions, 0 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 | } | ||