diff options
-rw-r--r-- | hosts/surtr/matrix/default.nix | 2 | ||||
-rw-r--r-- | hosts/surtr/postgresql.nix | 8 | ||||
-rw-r--r-- | overlays/ma1sd.nix | 60 |
3 files changed, 65 insertions, 5 deletions
diff --git a/hosts/surtr/matrix/default.nix b/hosts/surtr/matrix/default.nix index 9f076757..5b5b0112 100644 --- a/hosts/surtr/matrix/default.nix +++ b/hosts/surtr/matrix/default.nix | |||
@@ -258,7 +258,7 @@ | |||
258 | storage = { | 258 | storage = { |
259 | backend = "postgresql"; | 259 | backend = "postgresql"; |
260 | provider.postgresql = { | 260 | provider.postgresql = { |
261 | database = "//file%3A%2F%2F%2Frun%2Fpostgresql%2F.s.PGSQL.5432/ma1sd?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory%24URIScheme"; | 261 | database = "//file%3A%2F%2F%2Frun%2Fpostgresql%2F.s.PGSQL.5432/mxisd?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory%24URIScheme"; |
262 | }; | 262 | }; |
263 | }; | 263 | }; |
264 | forward.servers = ["matrix.org"]; | 264 | forward.servers = ["matrix.org"]; |
diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix index 88430823..e622f4e9 100644 --- a/hosts/surtr/postgresql.nix +++ b/hosts/surtr/postgresql.nix | |||
@@ -10,10 +10,10 @@ | |||
10 | GRANT ALL PRIVILEGES ON DATABASE "matrix-synapse" TO "matrix-synapse"; | 10 | GRANT ALL PRIVILEGES ON DATABASE "matrix-synapse" TO "matrix-synapse"; |
11 | GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "matrix-synapse"; | 11 | GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "matrix-synapse"; |
12 | 12 | ||
13 | CREATE DATABASE "ma1sd" WITH TEMPLATE "template0" ENCODING "UTF8" LOCALE "C"; | 13 | CREATE DATABASE "mxisd" WITH TEMPLATE "template0" ENCODING "UTF8" LOCALE "C"; |
14 | CREATE USER "ma1sd"; | 14 | CREATE USER "mxisd"; |
15 | GRANT ALL PRIVILEGES ON DATABASE "ma1sd" TO "ma1sd"; | 15 | GRANT ALL PRIVILEGES ON DATABASE "mxisd" TO "mxisd"; |
16 | GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "ma1sd"; | 16 | GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "mxisd"; |
17 | ''; | 17 | ''; |
18 | }; | 18 | }; |
19 | }; | 19 | }; |
diff --git a/overlays/ma1sd.nix b/overlays/ma1sd.nix new file mode 100644 index 00000000..3218879b --- /dev/null +++ b/overlays/ma1sd.nix | |||
@@ -0,0 +1,60 @@ | |||
1 | final: prev: { | ||
2 | ma1sd = let | ||
3 | pname = "ma1sd"; | ||
4 | version = "2.5.0"; | ||
5 | rev = version; | ||
6 | |||
7 | src = prev.fetchFromGitHub { | ||
8 | inherit rev; | ||
9 | owner = "ma1uta"; | ||
10 | repo = "ma1sd"; | ||
11 | hash = "sha256-K3kaujAhWsRQuTMW3SZOnE7Rmu8+tDXaxpLrb45OI4A="; | ||
12 | }; | ||
13 | |||
14 | |||
15 | deps = prev.stdenv.mkDerivation { | ||
16 | pname = "${pname}-deps"; | ||
17 | inherit src version; | ||
18 | nativeBuildInputs = with final; [ gradle_6 perl git ]; | ||
19 | |||
20 | buildPhase = '' | ||
21 | export MA1SD_BUILD_VERSION=${rev} | ||
22 | export GRADLE_USER_HOME=$(mktemp -d); | ||
23 | gradle --no-daemon build -x test | ||
24 | ''; | ||
25 | |||
26 | # perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar) | ||
27 | installPhase = '' | ||
28 | find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ | ||
29 | | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ | ||
30 | | sh | ||
31 | ''; | ||
32 | |||
33 | dontStrip = true; | ||
34 | |||
35 | outputHashAlgo = "sha256"; | ||
36 | outputHashMode = "recursive"; | ||
37 | outputHash = "sha256-P81aY1rOnZdb2UskPIrBe8dfWAicJ3TivBv/NEns5ro="; | ||
38 | }; | ||
39 | in prev.stdenv.mkDerivation { | ||
40 | inherit pname src version; | ||
41 | nativeBuildInputs = with final; [ gradle_6 perl makeWrapper ]; | ||
42 | buildInputs = with final; [ jre ]; | ||
43 | |||
44 | buildPhase = '' | ||
45 | runHook preBuild | ||
46 | export MA1SD_BUILD_VERSION=${rev} | ||
47 | export GRADLE_USER_HOME=$(mktemp -d) | ||
48 | sed -ie "s#mavenCentral()#mavenLocal(); maven { url '${deps}' }#g; s#mavenCentral()##g" build.gradle | ||
49 | gradle --offline --no-daemon build -x test | ||
50 | runHook postBuild | ||
51 | ''; | ||
52 | |||
53 | installPhase = '' | ||
54 | runHook preInstall | ||
55 | install -D build/libs/source.jar $out/lib/ma1sd.jar | ||
56 | makeWrapper ${final.jre}/bin/java $out/bin/ma1sd --add-flags "-jar $out/lib/ma1sd.jar" | ||
57 | runHook postInstall | ||
58 | ''; | ||
59 | }; | ||
60 | } | ||