Let's see if I can build cinny from source

This commit is contained in:
Lillian Violet 2024-06-19 11:26:11 +02:00
parent 26cd8835f5
commit 6e4e7a1b88
2 changed files with 53 additions and 25 deletions

View file

@ -4,40 +4,18 @@
inputs, inputs,
lib, 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 = { services.nginx = {
enable = true; enable = true;
virtualHosts = { virtualHosts = {
"cinny.gladtherescake.eu" = { "cinny.gladtherescake.eu" = {
root = "${pkgs.cinny}";
## Force HTTP redirect to HTTPS ## Force HTTP redirect to HTTPS
forceSSL = true; forceSSL = true;
## LetsEncrypt ## LetsEncrypt
enableACME = true; enableACME = true;
locations."/" = { locations."/" = {
proxyPass = "http://localhost:${toString port}"; index = "index.html";
proxyWebsockets = true;
}; };
}; };
}; };

50
pkgs/cinny/default.nix Normal file
View file

@ -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];
};
}