2024-01-25 14:12:00 +00:00
|
|
|
{ lib
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchNpmDeps
|
|
|
|
, npmHooks
|
|
|
|
, nodejs
|
2024-09-19 14:19:46 +00:00
|
|
|
, python3
|
2024-01-25 14:12:00 +00:00
|
|
|
, pkg-config
|
|
|
|
, sqlite
|
|
|
|
, zstd
|
|
|
|
, stdenv
|
|
|
|
, darwin
|
|
|
|
, open-policy-agent
|
|
|
|
}:
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "matrix-authentication-service";
|
2024-09-26 11:04:55 +00:00
|
|
|
version = "0.12.0";
|
2024-01-25 14:12:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2024-09-26 11:04:55 +00:00
|
|
|
owner = "element-hq";
|
2024-01-25 14:12:00 +00:00
|
|
|
repo = "matrix-authentication-service";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-26 11:04:55 +00:00
|
|
|
hash = "sha256-QLtyYxV2yXHJtwWgGcyi7gRcKypYoy9Z8bkEuTopVXc=";
|
2024-01-25 14:12:00 +00:00
|
|
|
};
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
|
|
|
"sea-query-0.32.0-rc.1" = "sha256-Q/NFiIBu8L5rQj4jwcIo8ACmAhLBy4HSTcJv06UdK8E=";
|
|
|
|
};
|
|
|
|
};
|
2024-01-25 14:12:00 +00:00
|
|
|
|
|
|
|
npmDeps = fetchNpmDeps {
|
|
|
|
name = "${pname}-${version}-npm-deps";
|
|
|
|
src = "${src}/${npmRoot}";
|
2024-09-26 11:04:55 +00:00
|
|
|
hash = "sha256-EfDxbdjzF0yLQlueIYKmdpU4v9dx7g8bltU63mIWfo0=";
|
2024-01-25 14:12:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
npmRoot = "frontend";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
open-policy-agent
|
|
|
|
npmHooks.npmConfigHook
|
|
|
|
nodejs
|
2024-09-19 14:19:46 +00:00
|
|
|
(python3.withPackages (ps: [ ps.setuptools ])) # Used by gyp
|
2024-01-25 14:12:00 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
sqlite
|
|
|
|
zstd
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-05-15 15:35:15 +00:00
|
|
|
darwin.apple_sdk_11_0.frameworks.CoreFoundation
|
|
|
|
darwin.apple_sdk_11_0.frameworks.Security
|
|
|
|
darwin.apple_sdk_11_0.frameworks.SystemConfiguration
|
2024-01-25 14:12:00 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
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)
|
|
|
|
'';
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
# Adopted from https://github.com/element-hq/matrix-authentication-service/blob/main/Dockerfile
|
2024-01-25 14:12:00 +00:00
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
meta = {
|
2024-01-25 14:12:00 +00:00
|
|
|
description = "OAuth2.0 + OpenID Provider for Matrix Homeservers";
|
2024-09-26 11:04:55 +00:00
|
|
|
homepage = "https://github.com/element-hq/matrix-authentication-service";
|
|
|
|
changelog = "https://github.com/element-hq/matrix-authentication-service/releases/tag/v${version}";
|
|
|
|
license = lib.licenses.agpl3Only;
|
|
|
|
maintainers = with lib.maintainers; [ teutat3s ];
|
2024-01-25 14:12:00 +00:00
|
|
|
mainProgram = "mas-cli";
|
|
|
|
};
|
|
|
|
}
|