summaryrefslogtreecommitdiff
path: root/com/simatime/fathom.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-11-02 15:33:13 -0700
committerBen Sima <ben@bsima.me>2019-11-02 15:33:13 -0700
commit9d114cfc773171b0a95bd4d2c39f1bb0eb783c8d (patch)
tree20766a760ed0141cf39153565e8552f6739c632d /com/simatime/fathom.nix
parentd2a37f5de160160eadbacd7b8dc2567f78a0543d (diff)
rename everything back to caps to appease ghc
Diffstat (limited to 'com/simatime/fathom.nix')
-rw-r--r--com/simatime/fathom.nix109
1 files changed, 0 insertions, 109 deletions
diff --git a/com/simatime/fathom.nix b/com/simatime/fathom.nix
deleted file mode 100644
index 40e8b0b..0000000
--- a/com/simatime/fathom.nix
+++ /dev/null
@@ -1,109 +0,0 @@
-{ options
-, lib
-, config
-, pkgs
-, modulesPath
-, stdenv
-}:
-
-with lib;
-
-let
- cfg = config.services.fathom
- pkgs.fathom = stdenv.mkDerivation rec {
- name = "fathom-v${version}";
- version = "1.2.1";
- src = builtins.fetchurl {
- url = "https://github.com/usefathom/fathom/releases/download/v${version}/fathom_${version}_linux_amd64.tar.gz";
- sha256 = "0sfpxh2xrvz992k0ynib57zzpcr0ikga60552i14m13wppw836nh";
- };
- sourceRoot = ".";
- dontBuild = true;
- installPhase = ''
- mkdir -p $out/bin
- cp fathom $out/bin
- cp LICENSE $out
- cp README.md $out
- '';
- };
-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";
- };
- };
- };
-}