diff options
author | Robert Schütz <nix@dotlambda.de> | 2023-02-15 20:02:50 -0800 |
---|---|---|
committer | Robert Schütz <nix@dotlambda.de> | 2023-02-16 11:19:45 -0800 |
commit | c6e2fbf1a2193d89675252314fa4d27b5ac6fff5 (patch) | |
tree | 1699ce188e8425ab045938600c8e5568ae6fccb5 /pkgs/tools/security | |
parent | 545c7a31e5dedea4a6d372712a18e00ce097d462 (diff) |
vaultwarden.webvault: build from source
Diffstat (limited to 'pkgs/tools/security')
-rw-r--r-- | pkgs/tools/security/vaultwarden/webvault.nix | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/pkgs/tools/security/vaultwarden/webvault.nix b/pkgs/tools/security/vaultwarden/webvault.nix index 74a75e24339cf..4e25c6f572fee 100644 --- a/pkgs/tools/security/vaultwarden/webvault.nix +++ b/pkgs/tools/security/vaultwarden/webvault.nix @@ -1,19 +1,61 @@ -{ lib, stdenv, fetchurl, nixosTests }: +{ lib +, buildNpmPackage +, fetchFromGitHub +, git +, nixosTests +, nodejs-16_x +, python3 +}: + +let + buildNpmPackage' = buildNpmPackage.override { nodejs = nodejs-16_x; }; -stdenv.mkDerivation rec { - pname = "vaultwarden-webvault"; version = "2022.12.0"; - src = fetchurl { - url = "https://github.com/dani-garcia/bw_web_builds/releases/download/v${version}/bw_web_v${version}.tar.gz"; - hash = "sha256-QC3/aqIF2NdJPHmwUbvJR62wsUGBrgsHJCyqBJ/0gMc="; + bw_web_builds = fetchFromGitHub { + owner = "dani-garcia"; + repo = "bw_web_builds"; + rev = "v${version}"; + hash = "sha256-4yUE0ySUCKmmbca+T8qjqSO0AHZEUAHZ4nheRjpDnZo="; }; +in buildNpmPackage' { + pname = "vaultwarden-webvault"; + inherit version; + + src = fetchFromGitHub { + owner = "bitwarden"; + repo = "clients"; + rev = "web-v${version}"; + hash = "sha256-CsbnnP12P7JuGDOm5Ia73SzET/jCx3qRbz9vdUf7lCA="; + }; + + npmDepsHash = "sha256-wWOtVGNOzY2s82nfQDuWgA4ukpJxJr8Z7Y+rFPq2QdU="; + + postPatch = '' + ln -s ${bw_web_builds}/{patches,resources} .. + PATH="${git}/bin:$PATH" VAULT_VERSION=${bw_web_builds.rev} \ + bash ${bw_web_builds}/scripts/apply_patches.sh + ''; + + nativeBuildInputs = [ + python3 + ]; + + makeCacheWritable = true; + + ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; + + npmBuildScript = "dist:oss:selfhost"; + + npmBuildFlags = [ + "--workspace" "apps/web" + ]; - buildCommand = '' - mkdir -p $out/share/vaultwarden/ - cd $out/share/vaultwarden/ - tar xf $src - mv web-vault vault + installPhase = '' + runHook preInstall + mkdir -p $out/share/vaultwarden + mv apps/web/build $out/share/vaultwarden/vault + runHook postInstall ''; passthru.tests = nixosTests.vaultwarden; @@ -23,6 +65,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/dani-garcia/bw_web_builds"; platforms = platforms.all; license = licenses.gpl3Plus; - maintainers = with maintainers; [ msteen mic92 ]; + maintainers = with maintainers; [ dotlambda msteen mic92 ]; }; } |