2022-02-19 21:31:06 +00:00
|
|
|
{
|
|
|
|
description = "Reddit -> Discord replicator";
|
|
|
|
|
|
|
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
|
|
|
inputs.utils.url = "github:numtide/flake-utils";
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, utils }:
|
|
|
|
utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages."${system}";
|
|
|
|
version = builtins.substring 0 8 self.lastModifiedDate;
|
|
|
|
in {
|
|
|
|
packages.snoo2nebby = pkgs.buildGoModule {
|
|
|
|
pname = "rhea";
|
|
|
|
inherit version;
|
|
|
|
src = ./.;
|
|
|
|
vendorSha256 = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultPackage = self.packages.${system}.snoo2nebby;
|
|
|
|
|
|
|
|
devShell = with pkgs;
|
2022-03-09 01:53:17 +00:00
|
|
|
mkShell { buildInputs = [ go gopls gotools bashInteractive ]; };
|
2022-02-19 21:31:06 +00:00
|
|
|
|
|
|
|
nixosModule = { config, lib, pkgs, ... }:
|
|
|
|
let cfg = config.within.services.snoo2nebby;
|
|
|
|
in with lib; {
|
|
|
|
options.within.services.snoo2nebby = {
|
|
|
|
enable = mkEnableOption
|
|
|
|
"enables snoo2nebby for crossposting from reddit to Discord";
|
|
|
|
subreddit = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "tulpas";
|
|
|
|
description =
|
|
|
|
"the subreddit name to monitor (the foo of /r/foo)";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.groups.within = mkDefault {};
|
|
|
|
users.users.snoo2nebby = {
|
|
|
|
createHome = true;
|
|
|
|
description = "tulpa.dev/cadey/snoo2nebby";
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "within";
|
|
|
|
home = "/srv/within/snoo2nebby";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.snoo2nebby = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "snoo2nebby-key.service" ];
|
|
|
|
wants = [ "snoo2nebby-key.service" ];
|
|
|
|
|
|
|
|
unitConfig.ConditionPathExists = "/srv/within/snoo2nebby/whurl.txt";
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = "snoo2nebby";
|
|
|
|
Group = "within";
|
|
|
|
Restart = "on-failure";
|
|
|
|
WorkingDirectory = "/srv/within/snoo2nebby";
|
|
|
|
RestartSec = "30s";
|
|
|
|
};
|
|
|
|
|
2022-02-19 21:54:23 +00:00
|
|
|
script = let pkg = self.defaultPackage.${system};
|
2022-02-19 21:31:06 +00:00
|
|
|
in ''
|
|
|
|
exec ${pkg}/bin/snoo2nebby -webhook-file /srv/within/snoo2nebby/whurl.txt -subreddit "${cfg.subreddit}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|