diff --git a/nixos/server/package-configs/cinny/default.nix b/nixos/server/package-configs/cinny/default.nix index 6c06e4a..6079856 100644 --- a/nixos/server/package-configs/cinny/default.nix +++ b/nixos/server/package-configs/cinny/default.nix @@ -4,40 +4,18 @@ inputs, lib, ... -}: let - port = 2143; - configFile = - pkgs.writeText "config.json" - '' - { - "defaultHomeserver": 0, - "homeserverList": [ - "matrix.gladtherescake.eu" - ], - "allowCustomHomeservers": false - } - ''; -in { - virtualisation.oci-containers.containers."cinny" = { - autoStart = true; - ports = ["${toString port}:80"]; - volumes = [ - "${configFile}:/app/config.json" - ]; - image = "ajbura/cinny:latest"; - }; - +}: { services.nginx = { enable = true; virtualHosts = { "cinny.gladtherescake.eu" = { + root = "${pkgs.cinny}"; ## Force HTTP redirect to HTTPS forceSSL = true; ## LetsEncrypt enableACME = true; locations."/" = { - proxyPass = "http://localhost:${toString port}"; - proxyWebsockets = true; + index = "index.html"; }; }; }; diff --git a/pkgs/cinny/default.nix b/pkgs/cinny/default.nix new file mode 100644 index 0000000..ed59af3 --- /dev/null +++ b/pkgs/cinny/default.nix @@ -0,0 +1,50 @@ +{ + lib, + buildNpmPackage, + fetchFromGitHub, + pkgs, +}: let + port = 2143; + configFile = + pkgs.writeText "config.json" + '' + { + "defaultHomeserver": 0, + "homeserverList": [ + "matrix.gladtherescake.eu" + ], + "allowCustomHomeservers": false + } + ''; +in + buildNpmPackage rec { + pname = "cinny"; + version = "09a0a2d"; + + src = fetchFromGitHub { + owner = "cinnyapp"; + repo = pname; + rev = "${version}"; + hash = "sha256-ee8YOJ0fGy26OWXb2Uumzy68M4UpERHH3ni0q+tDY14="; + }; + + npmDepsHash = "sha256-zelk15/rXXjhWuHj1GsSevnyXVBeDkMJ0qZfPyejq4A="; + + # The prepack script runs the build script, which we'd rather do in the build phase. + npmPackFlags = ["--ignore-scripts" "--max_old_space_size=4096"]; + + installPhase = '' + mkdir $out + npm run build + cp -r dist/* $out + mkdir $out/app + cp ${configFile} $out/app/config.json + ''; + + meta = with lib; { + description = "Yet another matrix client"; + homepage = "https://cinny.in/"; + license = licenses.agpl3O; + maintainers = with maintainers; [Lillian-Violet]; + }; + }