Loading pkgs/applications/misc/pagefind/default.nix +5 −31 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ fetchFromGitHub, fetchNpmDeps, fetchurl, httplz, binaryen, gzip, nodejs, Loading Loading @@ -88,30 +87,11 @@ rustPlatform.buildRustPackage rec { # patch a build-time dependency download ( realpath $cargoDepsCopy/* | grep lindera-unidic # debug for when version number changes cd $cargoDepsCopy/lindera-unidic-0.32.2 #oldHash=$(sha256sum build.rs | cut -d " " -f 1) # serve lindera-unidic on localhost vacant port httplz_port="${ if stdenv.buildPlatform.isDarwin then ''$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')'' else "34567" }" mkdir .lindera-http-plz ln -s ${lindera-unidic-src} .lindera-http-plz/unidic-mecab-2.1.2.tar.gz httplz --port "$httplz_port" -- .lindera-http-plz/ & echo $! >$TMPDIR/.httplz_pid # file:// does not work substituteInPlace build.rs --replace-fail \ "https://dlwqk3ibdg1xh.cloudfront.net/unidic-mecab-2.1.2.tar.gz" \ "http://localhost:$httplz_port/unidic-mecab-2.1.2.tar.gz" # not needed with useFetchCargoVendor=true, but kept in case it is required again #newHash=$(sha256sum build.rs | cut -d " " -f 1) #substituteInPlace .cargo-checksum.json --replace-fail $oldHash $newHash patch -d $cargoDepsCopy/lindera-assets-*/ -p1 < ${./lindera-assets-support-file-paths.patch} substituteInPlace $cargoDepsCopy/lindera-unidic-*/build.rs --replace-fail \ "${lindera-unidic-src.url}" \ "file://${lindera-unidic-src}" ) ''; Loading @@ -126,7 +106,6 @@ rustPlatform.buildRustPackage rec { rustc.llvmPackages.lld wasm-bindgen-cli_0_2_92 wasm-pack httplz ] ++ lib.optionals stdenv.buildPlatform.isDarwin [ python3 Loading Loading @@ -162,11 +141,6 @@ rustPlatform.buildRustPackage rec { ) ''; # the file is also fetched during checkPhase preInstall = '' kill ${lib.optionalString stdenv.hostPlatform.isDarwin "-9"} $(cat $TMPDIR/.httplz_pid) ''; buildFeatures = [ "extended" ]; doInstallCheck = true; Loading pkgs/applications/misc/pagefind/lindera-assets-support-file-paths.patch 0 → 100644 +30 −0 Original line number Diff line number Diff line diff --git a/src/lib.rs b/src/lib.rs index 6f86cc4..a9ca418 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -128,12 +128,17 @@ pub fn fetch(params: FetchParams, builder: impl DictionaryBuilder) -> Result<(), // copy(&source_path, &source_path_for_build)?; let tmp_path = Path::new(&build_dir).join(params.file_name.to_owned() + ".download"); + if let Some(path) = params.download_url.strip_prefix("file://") { + std::fs::copy(path, &tmp_path)?; + } + else { // Download a tarball let resp = ureq::get(params.download_url).call()?; let mut dest = File::create(&tmp_path)?; io::copy(&mut resp.into_reader(), &mut dest)?; dest.flush()?; + } rename(tmp_path, source_path_for_build).expect("Failed to rename temporary file"); @@ -153,7 +158,6 @@ pub fn fetch(params: FetchParams, builder: impl DictionaryBuilder) -> Result<(), archive.unpack(&tmp_extract_path)?; rename(tmp_extracted_path, &input_dir).expect("Failed to rename archive directory"); let _ = std::fs::remove_dir_all(&tmp_extract_path); - drop(dest); let _ = std::fs::remove_file(source_path_for_build); } Loading
pkgs/applications/misc/pagefind/default.nix +5 −31 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ fetchFromGitHub, fetchNpmDeps, fetchurl, httplz, binaryen, gzip, nodejs, Loading Loading @@ -88,30 +87,11 @@ rustPlatform.buildRustPackage rec { # patch a build-time dependency download ( realpath $cargoDepsCopy/* | grep lindera-unidic # debug for when version number changes cd $cargoDepsCopy/lindera-unidic-0.32.2 #oldHash=$(sha256sum build.rs | cut -d " " -f 1) # serve lindera-unidic on localhost vacant port httplz_port="${ if stdenv.buildPlatform.isDarwin then ''$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')'' else "34567" }" mkdir .lindera-http-plz ln -s ${lindera-unidic-src} .lindera-http-plz/unidic-mecab-2.1.2.tar.gz httplz --port "$httplz_port" -- .lindera-http-plz/ & echo $! >$TMPDIR/.httplz_pid # file:// does not work substituteInPlace build.rs --replace-fail \ "https://dlwqk3ibdg1xh.cloudfront.net/unidic-mecab-2.1.2.tar.gz" \ "http://localhost:$httplz_port/unidic-mecab-2.1.2.tar.gz" # not needed with useFetchCargoVendor=true, but kept in case it is required again #newHash=$(sha256sum build.rs | cut -d " " -f 1) #substituteInPlace .cargo-checksum.json --replace-fail $oldHash $newHash patch -d $cargoDepsCopy/lindera-assets-*/ -p1 < ${./lindera-assets-support-file-paths.patch} substituteInPlace $cargoDepsCopy/lindera-unidic-*/build.rs --replace-fail \ "${lindera-unidic-src.url}" \ "file://${lindera-unidic-src}" ) ''; Loading @@ -126,7 +106,6 @@ rustPlatform.buildRustPackage rec { rustc.llvmPackages.lld wasm-bindgen-cli_0_2_92 wasm-pack httplz ] ++ lib.optionals stdenv.buildPlatform.isDarwin [ python3 Loading Loading @@ -162,11 +141,6 @@ rustPlatform.buildRustPackage rec { ) ''; # the file is also fetched during checkPhase preInstall = '' kill ${lib.optionalString stdenv.hostPlatform.isDarwin "-9"} $(cat $TMPDIR/.httplz_pid) ''; buildFeatures = [ "extended" ]; doInstallCheck = true; Loading
pkgs/applications/misc/pagefind/lindera-assets-support-file-paths.patch 0 → 100644 +30 −0 Original line number Diff line number Diff line diff --git a/src/lib.rs b/src/lib.rs index 6f86cc4..a9ca418 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -128,12 +128,17 @@ pub fn fetch(params: FetchParams, builder: impl DictionaryBuilder) -> Result<(), // copy(&source_path, &source_path_for_build)?; let tmp_path = Path::new(&build_dir).join(params.file_name.to_owned() + ".download"); + if let Some(path) = params.download_url.strip_prefix("file://") { + std::fs::copy(path, &tmp_path)?; + } + else { // Download a tarball let resp = ureq::get(params.download_url).call()?; let mut dest = File::create(&tmp_path)?; io::copy(&mut resp.into_reader(), &mut dest)?; dest.flush()?; + } rename(tmp_path, source_path_for_build).expect("Failed to rename temporary file"); @@ -153,7 +158,6 @@ pub fn fetch(params: FetchParams, builder: impl DictionaryBuilder) -> Result<(), archive.unpack(&tmp_extract_path)?; rename(tmp_extracted_path, &input_dir).expect("Failed to rename archive directory"); let _ = std::fs::remove_dir_all(&tmp_extract_path); - drop(dest); let _ = std::fs::remove_file(source_path_for_build); }