diff options
Diffstat (limited to 'pkgs/by-name/ma/matrix-authentication-service/package.nix')
-rw-r--r-- | pkgs/by-name/ma/matrix-authentication-service/package.nix | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/pkgs/by-name/ma/matrix-authentication-service/package.nix b/pkgs/by-name/ma/matrix-authentication-service/package.nix new file mode 100644 index 0000000000000..ce4748af91d2b --- /dev/null +++ b/pkgs/by-name/ma/matrix-authentication-service/package.nix @@ -0,0 +1,97 @@ +{ lib +, rustPlatform +, fetchFromGitHub +, fetchNpmDeps +, npmHooks +, nodejs +, pkg-config +, sqlite +, zstd +, stdenv +, darwin +, open-policy-agent +}: + +rustPlatform.buildRustPackage rec { + pname = "matrix-authentication-service"; + version = "0.7.0"; + + src = fetchFromGitHub { + owner = "matrix-org"; + repo = "matrix-authentication-service"; + rev = "refs/tags/v${version}"; + hash = "sha256-foipChunzRKIbeO+O+XYx0luzaA0G9LKrH59luQl9R0="; + }; + + cargoLock = { + lockFile = ./Cargo.lock; + outputHashes = { + "opa-wasm-0.1.0" = "sha256-GuOlUNGegdDieTvthk9SyfQSTeem7ArJTdiD1t7Ojd4="; + }; + }; + + npmDeps = fetchNpmDeps { + name = "${pname}-${version}-npm-deps"; + src = "${src}/${npmRoot}"; + hash = "sha256-ymI+ZkPEGMTLMdTLfKv/v/cgW5iS/nd9PNXFvYaYNjo="; + }; + + npmRoot = "frontend"; + + nativeBuildInputs = [ + pkg-config + open-policy-agent + npmHooks.npmConfigHook + nodejs + ]; + + buildInputs = [ + sqlite + zstd + ] ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreFoundation + darwin.apple_sdk.frameworks.Security + darwin.apple_sdk.frameworks.SystemConfiguration + ]; + + env = { + ZSTD_SYS_USE_PKG_CONFIG = true; + }; + + buildNoDefaultFeatures = true; + + buildFeatures = [ "dist" ]; + + postPatch = '' + substituteInPlace crates/config/src/sections/http.rs \ + --replace ./frontend/dist/ "$out/share/$pname/assets/" + substituteInPlace crates/config/src/sections/templates.rs \ + --replace ./share/templates/ "$out/share/$pname/templates/" \ + --replace ./share/translations/ "$out/share/$pname/translations/" \ + --replace ./share/manifest.json "$out/share/$pname/assets/manifest.json" + substituteInPlace crates/config/src/sections/policy.rs \ + --replace ./share/policy.wasm "$out/share/$pname/policy.wasm" + ''; + + preBuild = '' + make -C policies + (cd "$npmRoot" && npm run build) + ''; + + # Adopted from https://github.com/matrix-org/matrix-authentication-service/blob/main/Dockerfile + postInstall = '' + install -Dm444 -t "$out/share/$pname" "policies/policy.wasm" + install -Dm444 -t "$out/share/$pname/assets" "$npmRoot/dist/"* + cp -r templates "$out/share/$pname/templates" + cp -r translations "$out/share/$pname/translations" + ''; + + meta = with lib; { + description = "OAuth2.0 + OpenID Provider for Matrix Homeservers"; + homepage = "https://github.com/matrix-org/matrix-authentication-service"; + changelog = "https://github.com/matrix-org/matrix-authentication-service/releases/tag/v${version}"; + license = licenses.asl20; + maintainers = with maintainers; [ teutat3s ]; + mainProgram = "mas-cli"; + }; +} |