From 668ba4d439d3b60ade9f96fd158ed293ff211f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 16 Oct 2021 15:56:32 +0200 Subject: Move Fiche to flakes --- flakes/fiche/flake.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++ modules/default.nix | 2 +- modules/webapps/fiche.nix | 53 ----------------------------------------------- 3 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 flakes/fiche/flake.nix delete mode 100644 modules/webapps/fiche.nix 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 @@ +{ + description = "Command line pastebin for sharing terminal output"; + + outputs = { self }: { + nixosModule = { config, lib, pkgs, ... }: { + options.services.fiche = { + enable = lib.mkEnableOption "Enable fiche’s service"; + port = lib.mkOption { + type = lib.types.port; + description = "Port to listen to"; + }; + domain = lib.mkOption { + type = lib.types.str; + description = "Domain"; + }; + dataDir = lib.mkOption { + type = lib.types.path; + default = "/var/lib/fiche"; + description = "Directory where to place the pastes"; + }; + https = lib.mkEnableOption "Use https"; + }; + + config = + let cfg = config.services.fiche; + in lib.mkIf cfg.enable { + networking.firewall.allowedTCPPorts = [ cfg.port ]; + + systemd.services.fiche = { + description = "Fiche server"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + script = '' + exec ${pkgs.fiche}/bin/fiche -o ${cfg.dataDir} -d ${cfg.domain} ${lib.optionalString cfg.https "-S "} -p ${builtins.toString cfg.port} + ''; + + serviceConfig = { + ExecStartPre = [ + "+${pkgs.coreutils}/bin/install -m 0755 -o fiche -d ${cfg.dataDir}" + ]; + DynamicUser = true; + User = "fiche"; + PrivateTmp = true; + Restart = "always"; + WorkingDirectory = cfg.dataDir; + ReadWritePaths = cfg.dataDir; + }; + }; + }; + }; + }; +} 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 mastodon = ./webapps/mastodon.nix; mediagoblin = ./webapps/mediagoblin.nix; peertube = (flakeCompat ../flakes/peertube).nixosModule; - fiche = ./webapps/fiche.nix; + fiche = flakeLib.withNarKeyCompat flakeCompat ../flakes/fiche "nixosModule"; paste = flakeLib.withNarKeyCompat flakeCompat ../flakes/paste "nixosModule"; 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 @@ -{ lib, pkgs, config, ... }: -let - cfg = config.services.fiche; -in -{ - options.services.fiche = { - enable = lib.mkEnableOption "Enable fiche’s service"; - port = lib.mkOption { - type = lib.types.port; - description = "Port to listen to"; - }; - domain = lib.mkOption { - type = lib.types.str; - description = "Domain"; - }; - dataDir = lib.mkOption { - type = lib.types.path; - default = "/var/lib/fiche"; - description = "Directory where to place the pastes"; - }; - https = lib.mkEnableOption "Use https"; - }; - - config = lib.mkIf cfg.enable { - networking.firewall.allowedTCPPorts = [ cfg.port ]; - - - system.activationScripts.fiche = '' - mkdir -p /var/lib/fiche - ''; - systemd.services.fiche = { - description = "Fiche server"; - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; - - script = '' - exec ${pkgs.fiche}/bin/fiche -o ${cfg.dataDir} -d ${cfg.domain} ${lib.optionalString cfg.https "-S "} -p ${builtins.toString cfg.port} - ''; - - serviceConfig = { - ExecStartPre = [ - "+${pkgs.coreutils}/bin/install -m 0755 -o fiche -d /var/lib/fiche" - ]; - DynamicUser = true; - User = "fiche"; - PrivateTmp = true; - Restart = "always"; - WorkingDirectory = cfg.dataDir; - ReadWritePaths = cfg.dataDir; - }; - }; - }; -} -- cgit v1.2.3