diff options
Diffstat (limited to 'nix')
-rw-r--r-- | nix/hosts/corrino/remarvin.nix | 17 | ||||
-rw-r--r-- | nix/hosts/corrino/secrets/remarvin_accesstoken.age | 9 | ||||
-rw-r--r-- | nix/modules/remarvin/default.nix | 70 | ||||
-rw-r--r-- | nix/pkgs/remarvin/default.nix | 35 |
4 files changed, 131 insertions, 0 deletions
diff --git a/nix/hosts/corrino/remarvin.nix b/nix/hosts/corrino/remarvin.nix new file mode 100644 index 0000000..580cbbf --- /dev/null +++ b/nix/hosts/corrino/remarvin.nix @@ -0,0 +1,17 @@ +{ config, ... }: + +{ + # deploy: + # - push code + # - build in order to get the new hash (nix build .#remarvin) + # - update hash in the package (//nix/pkgs/remarvin/default.nix) + # - deploy + + services.emile.remarvin = { + enable = true; + + username = "marvin_test1"; + homeserver = "matrix.org"; + accesstoken = config.age.secrets.remarvin_accesstoken.path; + }; +} diff --git a/nix/hosts/corrino/secrets/remarvin_accesstoken.age b/nix/hosts/corrino/secrets/remarvin_accesstoken.age new file mode 100644 index 0000000..b842818 --- /dev/null +++ b/nix/hosts/corrino/secrets/remarvin_accesstoken.age @@ -0,0 +1,9 @@ +age-encryption.org/v1 +-> ssh-ed25519 gvwQ2Q RznnGznMNzcDCJqkrBtyE05mP9IbZEXImcR6k5pqLxc +1BD28vqjYZsizyWYDr2C5ZE/mTuXGrJsNyALyhP0NUM +-> ssh-ed25519 m8VklA Ckn4D1R2SMGtWDRZQHfUSXFYV0KwE9LqbTRtfhbycxw +8m4HG/1HVbBRQ/Et87KUr7krzctJ7OnAbI07bvIXbm4 +--- QXOHuhdZoZfjFoD3f8eePfAmy+W/a/9vjmVwY9PHgEU +[ i^v_R$0ldeDN(\17!xS;[rfN?Om +z< ++[ \ No newline at end of file diff --git a/nix/modules/remarvin/default.nix b/nix/modules/remarvin/default.nix new file mode 100644 index 0000000..d95e3f2 --- /dev/null +++ b/nix/modules/remarvin/default.nix @@ -0,0 +1,70 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.emile.remarvin; +in +with lib; +{ + options.services.emile.remarvin = { + enable = mkEnableOption "Enable remarvin"; + + # ip and port to listen on + host = mkOption { + type = types.str; + default = "127.0.0.1"; + example = "0.0.0.0"; + description = "The host the service listens on"; + }; + + port = mkOption { + type = types.int; + default = 8080; + example = 8080; + description = "The port the service listens on"; + }; + + # env vars with secrets to set + username = mkOption { + type = types.str; + default = ""; + example = "remarvin"; + description = "The username of the bot (without @ or homeserver)"; + }; + + homeserver = mkOption { + type = types.str; + default = ""; + example = "matrix.org"; + description = "The homeserver to use"; + }; + + accesstoken = mkOption { + type = types.str; + default = ""; + example = "syt_bWFy2mluX34lc3Qx_VARzpUOQIzyzCHunCDnd_1hbPka"; + description = "The accesstoken used to authenticat (element web > settings > help & about > advanced > access token)"; + }; + }; + + config = mkIf cfg.enable { + systemd.services.remarvin = { + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + RestartSec = 5; + Restart = "always"; + }; + environment = { + SESSION_KEY = cfg.sessionKey; + SALT = cfg.salt; + VERSION = pkgs.r2wars-web.version; + }; + path = [ pkgs.remarvin ]; + serviceConfig.ExecStart = "${pkgs.remarvin}/bin/remarvin -homeserver ${cfg.homeserver} -username ${cfg.username} -accesstoken ${cfg.accesstoken}"; + }; + }; +} diff --git a/nix/pkgs/remarvin/default.nix b/nix/pkgs/remarvin/default.nix new file mode 100644 index 0000000..1da157f --- /dev/null +++ b/nix/pkgs/remarvin/default.nix @@ -0,0 +1,35 @@ +{ + pkgs, + lib, + fetchgit, +}: + +pkgs.buildGoModule rec { + name = "remarvin-${version}"; + version = "0.1.1"; + + src = fetchgit { + url = "git://git.emile.space/remarvin.git"; + hash = "sha256-UahNwhsxFGSpaVTk2EFtjt/MCB4Ec/08QStylL2QPUM="; + }; + + vendorHash = null; + CGO_ENABLED = 0; + subPackages = [ "src" ]; + + postInstall = '' + mkdir -p $out + cp -r templates $out + + mv $out/bin/src $out/bin/remarvin + ''; + + doCheck = false; + + meta = { + description = "A small marvin bot"; + homepage = src.url; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ hanemile ]; + }; +} |