parent
26bed9bbd8
commit
927ab18ee5
|
@ -1 +1,3 @@
|
|||
var/*
|
||||
var/*
|
||||
result
|
||||
.direnv
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
(import (fetchTarball {
|
||||
url =
|
||||
"https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
|
||||
}) { src = ./.; }).defaultNix
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1644525281,
|
||||
"narHash": "sha256-D3VuWLdnLmAXIkooWAtbTGSQI9Fc1lkvAr94wTxhnTU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "48d63e924a2666baf37f4f14a18f19347fbd54a2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
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;
|
||||
mkShell { buildInputs = [ go gopls goimports bashInteractive ]; };
|
||||
|
||||
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";
|
||||
};
|
||||
|
||||
script = let pkg = pkgs.tulpa.dev.cadey.snoo2nebby;
|
||||
in ''
|
||||
exec ${pkg}/bin/snoo2nebby -webhook-file /srv/within/snoo2nebby/whurl.txt -subreddit "${cfg.subreddit}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
12
shell.nix
12
shell.nix
|
@ -1,5 +1,7 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [ go gopls goimports bashInteractive ];
|
||||
}
|
||||
(import (
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).shellNix
|
||||
|
|
Reference in New Issue