Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ binaryen 2, fetchFromGitHub 3, fetchpatch 4, fetchzip 5, lib 6, lldap 7, nixosTests 8, rustPlatform 9, rustc 10, stdenv 11, wasm-bindgen-cli 12, wasm-pack 13, which 14}: 15 16let 17 18 # replace with upstream wasm rustc, after resolution of 19 # https://github.com/NixOS/nixpkgs/issues/89426 20 rustc-wasm = (rustc.override { 21 stdenv = stdenv.override { 22 targetPlatform = stdenv.targetPlatform // { 23 parsed = { 24 cpu.name = "wasm32"; 25 vendor.name = "unknown"; 26 kernel.name = "unknown"; 27 abi.name = "unknown"; 28 }; 29 }; 30 }; 31 }).overrideAttrs (attrs: { 32 configureFlags = attrs.configureFlags ++ ["--set=build.docs=false"]; 33 }); 34 35 commonDerivationAttrs = rec { 36 pname = "lldap"; 37 version = "0.4.3"; 38 39 src = fetchFromGitHub { 40 owner = "lldap"; 41 repo = "lldap"; 42 rev = "v${version}"; 43 hash = "sha256-FAUTykFh2eGVpx6LrCjV9xWbBPH8pCgAJv3vOXFMFZ4="; 44 }; 45 46 postPatch = '' 47 ln -s --force ${./Cargo.lock} Cargo.lock 48 ''; 49 50 # `Cargo.lock` has git dependencies, meaning can't use `cargoHash` 51 cargoLock = { 52 # 0.4.3 has been tagged before the actual Cargo.lock bump, resulting in an inconsitent lock file. 53 # To work around this, the Cargo.lock below is from the commit right after the tag: 54 # https://github.com/lldap/lldap/commit/7b4188a376baabda48d88fdca3a10756da48adda 55 lockFile = ./Cargo.lock; 56 outputHashes = { 57 "lber-0.4.1" = "sha256-2rGTpg8puIAXggX9rEbXPdirfetNOHWfFc80xqzPMT4="; 58 "opaque-ke-0.6.1" = "sha256-99gaDv7eIcYChmvOKQ4yXuaGVzo2Q6BcgSQOzsLF+fM="; 59 "yew_form-0.1.8" = "sha256-1n9C7NiFfTjbmc9B5bDEnz7ZpYJo9ZT8/dioRXJ65hc="; 60 }; 61 }; 62 }; 63 64 frontend = rustPlatform.buildRustPackage (commonDerivationAttrs // { 65 pname = commonDerivationAttrs.pname + "-frontend"; 66 67 nativeBuildInputs = [ 68 wasm-pack wasm-bindgen-cli binaryen which rustc-wasm rustc-wasm.llvmPackages.lld 69 ]; 70 71 buildPhase = '' 72 HOME=`pwd` RUSTFLAGS="-C linker=lld" ./app/build.sh 73 ''; 74 75 installPhase = '' 76 mkdir -p $out 77 cp -R app/{index.html,pkg,static} $out/ 78 ''; 79 80 doCheck = false; 81 }); 82 83in rustPlatform.buildRustPackage (commonDerivationAttrs // { 84 85 cargoBuildFlags = [ "-p" "lldap" "-p" "migration-tool" "-p" "lldap_set_password" ]; 86 87 patches = [ 88 ./static-frontend-path.patch 89 ]; 90 91 postPatch = commonDerivationAttrs.postPatch + '' 92 substituteInPlace server/src/infra/tcp_server.rs --subst-var-by frontend '${frontend}' 93 ''; 94 95 postInstall = '' 96 mv $out/bin/migration-tool $out/bin/lldap_migration_tool 97 ''; 98 99 passthru = { 100 inherit frontend; 101 tests = { 102 inherit (nixosTests) lldap; 103 }; 104 }; 105 106 meta = with lib; { 107 description = "A lightweight authentication server that provides an opinionated, simplified LDAP interface for authentication"; 108 homepage = "https://github.com/lldap/lldap"; 109 changelog = "https://github.com/lldap/lldap/blob/v${lldap.version}/CHANGELOG.md"; 110 license = licenses.gpl3Only; 111 platforms = platforms.linux; 112 maintainers = with maintainers; [ emilylange bendlas ]; 113 }; 114})