Merge pull request #67890 from mguentner/mxisd_ma1sd

mxisd: 1.4.5 -> 1.4.6 ☺ ma1sd: init at 2.1.1
This commit is contained in:
Franz Pletz 2019-10-09 14:36:56 +00:00 committed by GitHub
commit f024e7b769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 133 additions and 16 deletions

View File

@ -3,6 +3,15 @@
with lib; with lib;
let let
isMa1sd =
package:
lib.hasPrefix "ma1sd" package.name;
isMxisd =
package:
lib.hasPrefix "mxisd" package.name;
cfg = config.services.mxisd; cfg = config.services.mxisd;
server = optionalAttrs (cfg.server.name != null) { inherit (cfg.server) name; } server = optionalAttrs (cfg.server.name != null) { inherit (cfg.server) name; }
@ -12,37 +21,41 @@ let
matrix.domain = cfg.matrix.domain; matrix.domain = cfg.matrix.domain;
key.path = "${cfg.dataDir}/signing.key"; key.path = "${cfg.dataDir}/signing.key";
storage = { storage = {
provider.sqlite.database = "${cfg.dataDir}/mxisd.db"; provider.sqlite.database = if isMa1sd cfg.package
then "${cfg.dataDir}/ma1sd.db"
else "${cfg.dataDir}/mxisd.db";
}; };
} // optionalAttrs (server != {}) { inherit server; }; } // optionalAttrs (server != {}) { inherit server; };
# merges baseConfig and extraConfig into a single file # merges baseConfig and extraConfig into a single file
fullConfig = recursiveUpdate baseConfig cfg.extraConfig; fullConfig = recursiveUpdate baseConfig cfg.extraConfig;
configFile = pkgs.writeText "mxisd-config.yaml" (builtins.toJSON fullConfig); configFile = if isMa1sd cfg.package
then pkgs.writeText "ma1sd-config.yaml" (builtins.toJSON fullConfig)
else pkgs.writeText "mxisd-config.yaml" (builtins.toJSON fullConfig);
in { in {
options = { options = {
services.mxisd = { services.mxisd = {
enable = mkEnableOption "mxisd matrix federated identity server"; enable = mkEnableOption "matrix federated identity server";
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = pkgs.mxisd; default = pkgs.mxisd;
defaultText = "pkgs.mxisd"; defaultText = "pkgs.mxisd";
description = "The mxisd package to use"; description = "The mxisd/ma1sd package to use";
}; };
dataDir = mkOption { dataDir = mkOption {
type = types.str; type = types.str;
default = "/var/lib/mxisd"; default = "/var/lib/mxisd";
description = "Where data mxisd uses resides"; description = "Where data mxisd/ma1sd uses resides";
}; };
extraConfig = mkOption { extraConfig = mkOption {
type = types.attrs; type = types.attrs;
default = {}; default = {};
description = "Extra options merged into the mxisd configuration"; description = "Extra options merged into the mxisd/ma1sd configuration";
}; };
matrix = { matrix = {
@ -62,7 +75,7 @@ in {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = '' description = ''
Public hostname of mxisd, if different from the Matrix domain. Public hostname of mxisd/ma1sd, if different from the Matrix domain.
''; '';
}; };
@ -103,11 +116,13 @@ in {
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = let
executable = if isMa1sd cfg.package then "ma1sd" else "mxisd";
in {
Type = "simple"; Type = "simple";
User = "mxisd"; User = "mxisd";
Group = "mxisd"; Group = "mxisd";
ExecStart = "${cfg.package}/bin/mxisd -c ${configFile}"; ExecStart = "${cfg.package}/bin/${executable} -c ${configFile}";
WorkingDirectory = cfg.dataDir; WorkingDirectory = cfg.dataDir;
Restart = "on-failure"; Restart = "on-failure";
}; };

View File

@ -10,12 +10,22 @@ import ./make-test.nix ({ pkgs, ... } : {
services.mxisd.enable = true; services.mxisd.enable = true;
services.mxisd.matrix.domain = "example.org"; services.mxisd.matrix.domain = "example.org";
}; };
server_ma1sd = args : {
services.mxisd.enable = true;
services.mxisd.matrix.domain = "example.org";
services.mxisd.package = pkgs.ma1sd;
};
}; };
testScript = '' testScript = ''
startAll; startAll;
$server_mxisd->waitForUnit("mxisd.service"); $server_mxisd->waitForUnit("mxisd.service");
$server_mxisd->waitForOpenPort(8090); $server_mxisd->waitForOpenPort(8090);
$server_mxisd->succeed("curl -Ssf \"http://127.0.0.1:8090/_matrix/identity/api/v1\"") $server_mxisd->succeed("curl -Ssf \"http://127.0.0.1:8090/_matrix/identity/api/v1\"");
$server_ma1sd->waitForUnit("mxisd.service");
$server_ma1sd->waitForOpenPort(8090);
$server_ma1sd->succeed("curl -Ssf \"http://127.0.0.1:8090/_matrix/identity/api/v1\"")
''; '';
}) })

View File

@ -0,0 +1,20 @@
--- a/build.gradle 2019-09-01 16:17:17.815513296 +0200
+++ b/build.gradle 2019-09-01 16:21:14.688832785 +0200
@@ -73,7 +73,7 @@
buildscript {
repositories {
- jcenter()
+REPLACE
}
dependencies {
@@ -83,7 +83,7 @@
}
repositories {
- jcenter()
+REPLACE
}
dependencies {

View File

@ -0,0 +1,70 @@
{ stdenv, fetchFromGitHub, jre, git, gradle_5, perl, makeWrapper }:
let
name = "ma1sd-${version}";
version = "2.1.1";
rev = "a112a5e57cb38ad282939d2dcb9c1476e038af39";
src = fetchFromGitHub {
inherit rev;
owner = "ma1uta";
repo = "ma1sd";
sha256 = "1qibn6m6mvxwnbiypxlgkaqg6in358vkf0q47410rv1dx1gjcnv5";
};
deps = stdenv.mkDerivation {
name = "${name}-deps";
inherit src;
nativeBuildInputs = [ gradle_5 perl git ];
buildPhase = ''
export MA1SD_BUILD_VERSION=${rev}
export GRADLE_USER_HOME=$(mktemp -d);
gradle --no-daemon build -x test
'';
# 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)
installPhase = ''
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
'';
dontStrip = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "1w9cxq0rlzyh7bzqr3v3vn2cjhpn7hhc5lk9qzwj7sdj4jn2qxq6";
};
in
stdenv.mkDerivation {
inherit name src version;
nativeBuildInputs = [ gradle_5 perl makeWrapper ];
buildInputs = [ jre ];
patches = [ ./0001-gradle.patch ];
buildPhase = ''
export MA1SD_BUILD_VERSION=${rev}
export GRADLE_USER_HOME=$(mktemp -d)
sed -ie "s#REPLACE#mavenLocal(); maven { url '${deps}' }#g" build.gradle
gradle --offline --no-daemon build -x test
'';
installPhase = ''
install -D build/libs/source.jar $out/lib/ma1sd.jar
makeWrapper ${jre}/bin/java $out/bin/ma1sd --add-flags "-jar $out/lib/ma1sd.jar"
'';
meta = with stdenv.lib; {
description = "a federated matrix identity server; fork of mxisd";
homepage = https://github.com/ma1uta/ma1sd;
license = licenses.agpl3;
maintainers = with maintainers; [ mguentner ];
platforms = platforms.all;
};
}

View File

@ -1,22 +1,22 @@
{ stdenv, fetchFromGitHub, jre, git, gradle_4_10, perl, makeWrapper }: { stdenv, fetchFromGitHub, jre, git, gradle_4, perl, makeWrapper }:
let let
name = "mxisd-${version}"; name = "mxisd-${version}";
version = "1.4.5"; version = "1.4.6";
rev = "a964b073bfa7552e94fe51f48e18830b1051b0b7"; rev = "6e9601cb3a18281857c3cefd20ec773023b577d2";
src = fetchFromGitHub { src = fetchFromGitHub {
inherit rev; inherit rev;
owner = "kamax-matrix"; owner = "kamax-matrix";
repo = "mxisd"; repo = "mxisd";
sha256 = "1h1lx531rjswh0m2zdsmfizrkkx9bh414v9m321hbbfzk3f98fkk"; sha256 = "07gpdgbz281506p2431qn92bvdza6ap3jfq5b7xdm7nwrry80pzd";
}; };
deps = stdenv.mkDerivation { deps = stdenv.mkDerivation {
name = "${name}-deps"; name = "${name}-deps";
inherit src; inherit src;
nativeBuildInputs = [ gradle_4_10 perl git ]; nativeBuildInputs = [ gradle_4 perl git ];
buildPhase = '' buildPhase = ''
export MXISD_BUILD_VERSION=${rev} export MXISD_BUILD_VERSION=${rev}
@ -41,7 +41,7 @@ let
in in
stdenv.mkDerivation { stdenv.mkDerivation {
inherit name src version; inherit name src version;
nativeBuildInputs = [ gradle_4_10 perl makeWrapper ]; nativeBuildInputs = [ gradle_4 perl makeWrapper ];
buildInputs = [ jre ]; buildInputs = [ jre ];
patches = [ ./0001-gradle.patch ]; patches = [ ./0001-gradle.patch ];

View File

@ -4331,6 +4331,8 @@ in
kzipmix = pkgsi686Linux.callPackage ../tools/compression/kzipmix { }; kzipmix = pkgsi686Linux.callPackage ../tools/compression/kzipmix { };
ma1sd = callPackage ../servers/ma1sd { };
mailcatcher = callPackage ../development/web/mailcatcher { }; mailcatcher = callPackage ../development/web/mailcatcher { };
makebootfat = callPackage ../tools/misc/makebootfat { }; makebootfat = callPackage ../tools/misc/makebootfat { };