summaryrefslogtreecommitdiff
path: root/flake.nix
blob: df77653acaae12e60fb6470630b505df7cee1a05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
  outputs = { nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
        cesspool = pkgs.rustPlatform.buildRustPackage {
          pname = "cesspool";
          version = "0.1.0";
          cargoLock.lockFile = ./Cargo.lock;
          src = ./.;
        };
      in {
        defaultPackage = cesspool;
        packages.cesspool = cesspool;
        nixosModule = { config, lib, ... }: {
          options.services.cesspool = {
            enable = lib.mkEnableOption
              "Enables cesspool, a Discord thread unarchivization notifier.";
            tokenPath = lib.mkOption { type = lib.types.path; };
          };
          config.systemd.services.cesspool = with config.services.cesspool; {
            inherit enable;
            description =
              "Discord bot that notifies when threads are unarchived";
            wantedBy = [ "multi-user.target" ];
            wants = [ "network-online.target" ];
            script = ''
              export CESSPOOL_TOKEN=$(cat ${tokenPath})
              ${cesspool}/bin/cesspool
            '';
          };
        };
      });
}