summaryrefslogtreecommitdiff
path: root/mode/fathom.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-10-27 09:48:52 -0700
committerBen Sima <ben@bsima.me>2019-10-27 12:14:40 -0700
commitc790672cc244ac4caba1bda3572829a6c6862891 (patch)
tree2706bb8044f7b14840c5f90f215b79b433e81045 /mode/fathom.nix
parent44df4ba39f65c3afd84bee6b03f47d9b061e9038 (diff)
move everything to namespace directories
Diffstat (limited to 'mode/fathom.nix')
-rw-r--r--mode/fathom.nix93
1 files changed, 0 insertions, 93 deletions
diff --git a/mode/fathom.nix b/mode/fathom.nix
deleted file mode 100644
index dee34b9..0000000
--- a/mode/fathom.nix
+++ /dev/null
@@ -1,93 +0,0 @@
-{ options
-, lib
-, config
-, pkgs
-, modulesPath
-}:
-
-with lib;
-
-let
- cfg = config.services.fathom;
-in
-{
- options.services.fathom = {
- enable = lib.mkEnableOption "Enable the Fathom Analytics service";
-
- port = mkOption {
- type = types.string;
- default = "3000";
- description = ''
- The port on which Fathom will listen for
- incoming HTTP traffic.
- '';
- };
-
- gzip = mkOption {
- type = types.bool;
- default = true;
- description = "Whether or not to enable gzip compression.";
- };
-
- debug = mkOption {
- type = types.bool;
- default = false;
- description = "Whether or not to enable debug mode.";
- };
-
- dataDir = mkOption {
- type = types.path;
- default = "/var/lib/fathom";
- description = "Fathom data directory";
- };
- };
-
- config = mkIf cfg.enable {
- systemd.services.fathom = {
- wantedBy = [ "multi-user.target" ];
- after = [ "network.target" ];
-
- environment = {
- FATHOM_SERVER_ADDR = cfg.port;
- FATHOM_GZIP = builtins.toString cfg.gzip;
- FATHOM_DEBUG = builtins.toString cfg.debug;
- FATHOM_DATABASE_DRIVER = "sqlite3";
- FATHOM_DATABASE_NAME = "${cfg.dataDir}/fathom.db";
- FATHOM_SECRET = "random-secret-string";
- };
- preStart = ''
- echo "[fathom] creating ${cfg.dataDir}"
- mkdir -p ${cfg.dataDir}
- chown -R fathom:fathom ${cfg.dataDir}
- echo "[fathom]" creating ${cfg.dataDir}/.env
- env | grep "^FATHOM" > ${cfg.dataDir}/.env
- '';
- description = ''
- Fathom Analytics
- '';
-
- serviceConfig = {
- Type = "simple";
- User = "fathom";
- Group = "fathom";
- ExecStart = "${pkgs.fathom}/bin/fathom server";
- KillSignal = "INT";
- WorkingDirectory = cfg.dataDir;
- Restart = "on-failure";
- RestartSec = "10";
- PermissionsStartOnly = "true";
- };
- };
-
- environment.systemPackages = [ pkgs.fathom ];
-
- users = {
- groups = { fathom = {}; };
- users.fathom = {
- description = "Fathom daemon user";
- home = cfg.dataDir;
- group = "fathom";
- };
- };
- };
-}