diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2020-06-01 22:31:10 +0200 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2020-06-02 15:25:05 +0200 |
commit | 642e9916c6f7013ea4d99ebe927686dcf846394b (patch) | |
tree | fa1283a79158f78604b09ca4a0baa7bfdc4e650c /nixos/modules/services | |
parent | b6f084797a4f4e38b6fdca49c750f8ea017f3e0a (diff) | |
download | nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.tar nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.tar.gz nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.tar.bz2 nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.tar.lz nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.tar.xz nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.tar.zst nixlib-642e9916c6f7013ea4d99ebe927686dcf846394b.zip |
nixos/go-neb: init
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/networking/go-neb.nix | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/go-neb.nix b/nixos/modules/services/networking/go-neb.nix new file mode 100644 index 000000000000..991ae38f30a5 --- /dev/null +++ b/nixos/modules/services/networking/go-neb.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.go-neb; + + configFile = pkgs.writeText "config.yml" (builtins.toJSON cfg.config); +in { + options.services.go-neb = { + enable = mkEnableOption "Extensible matrix bot written in Go"; + + bindAddress = mkOption { + type = types.str; + description = "Port (and optionally address) to listen on."; + default = ":4050"; + }; + + baseUrl = mkOption { + type = types.str; + description = "Public-facing endpoint that can receive webhooks."; + }; + + config = mkOption { + type = types.uniq types.attrs; + description = '' + Your <filename>config.yaml</filename> as a Nix attribute set. + See <link xlink:href="https://github.com/matrix-org/go-neb/blob/master/config.sample.yaml">config.sample.yaml</link> + for possible options. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.services.go-neb = { + description = "Extensible matrix bot written in Go"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + environment = { + BASE_URL = cfg.baseUrl; + BIND_ADDRESS = cfg.bindAddress; + CONFIG_FILE = configFile; + }; + + serviceConfig = { + ExecStart = "${pkgs.go-neb}/bin/go-neb"; + DynamicUser = true; + }; + }; + }; + + meta.maintainers = with maintainers; [ hexa maralorn ]; +} |