forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#305348 from JohnRTitor/rnnoise
rnnoise: 2021-01-22 -> 0.2
- Loading branch information
Showing
2 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,84 @@ | ||
{ stdenv, lib, fetchFromGitHub, autoreconfHook }: | ||
{ stdenv, lib, fetchurl, fetchzip, autoreconfHook, writeScript, fetchpatch | ||
, modelUrl ? "", modelHash ? "" # Allow overriding the model URL and hash | ||
}: | ||
|
||
stdenv.mkDerivation (rec { | ||
let | ||
modelVersionJSON = lib.importJSON ./model-version.json; | ||
|
||
# Copy from https://gitlab.xiph.org/xiph/rnnoise/-/raw/v${version}/model_version | ||
default_model_version = modelVersionJSON.version; | ||
|
||
# Either use the default model or the one provided by package override | ||
model_url = if (modelUrl == "") then "https://media.xiph.org/rnnoise/models/rnnoise_data-${default_model_version}.tar.gz" else modelUrl; | ||
model_hash = if (modelHash == "") then modelVersionJSON.hash else modelHash; | ||
|
||
in stdenv.mkDerivation (finalAttrs: { | ||
pname = "rnnoise"; | ||
version = "2021-01-22"; | ||
version = "0.2"; | ||
|
||
src = fetchzip { | ||
urls = [ | ||
"https://gitlab.xiph.org/xiph/rnnoise/-/archive/v${finalAttrs.version}/rnnoise-v${finalAttrs.version}.tar.gz" | ||
"https://github.com/xiph/rnnoise/archive/v${finalAttrs.version}.tar.gz" | ||
]; | ||
hash = "sha256-Qaf+0iOprq7ILRWNRkBjsniByctRa/lFVqiU5ZInF/Q="; | ||
}; | ||
|
||
patches = [ | ||
# remove when updating | ||
(fetchpatch { | ||
url = "https://github.com/xiph/rnnoise/commit/372f7b4b76cde4ca1ec4605353dd17898a99de38.patch"; | ||
hash = "sha256-Dzikb59hjVxd1XIEj/Je4evxtGORkaNcqE+zxOJMSvs="; | ||
}) | ||
]; | ||
|
||
src = fetchFromGitHub { | ||
owner = "xiph"; | ||
repo = "rnnoise"; | ||
rev = "1cbdbcf1283499bbb2230a6b0f126eb9b236defd"; | ||
sha256 = "1y0rzgmvy8bf9a431garpm2w177s6ajgf79y5ymw4yb0pik57rwb"; | ||
model = fetchurl { | ||
url = model_url; | ||
hash = model_hash; | ||
}; | ||
|
||
postPatch = '' | ||
tar xvomf ${finalAttrs.model} | ||
''; | ||
|
||
nativeBuildInputs = [ autoreconfHook ]; | ||
|
||
postInstall = '' | ||
install -Dt $out/bin examples/.libs/rnnoise_demo | ||
''; | ||
|
||
meta = with lib; { | ||
passthru.updateScript = writeScript "update-rnnoise.sh" '' | ||
#!/usr/bin/env nix-shell | ||
#!nix-shell -i bash -p curl jq common-updater-scripts nix nix-prefetch findutils moreutils | ||
prefetch-sri() { | ||
nix-prefetch-url "$1" | xargs nix hash to-sri --type sha256 | ||
} | ||
res="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ | ||
-sL "https://api.github.com/repos/xiph/rnnoise/tags?per_page=1")" | ||
version="$(echo $res | jq '.[0].name | split("v") | .[1]' --raw-output)" | ||
update-source-version ${finalAttrs.pname} "$version" --ignore-same-hash | ||
model_version=$(curl -sL "https://raw.githubusercontent.com/xiph/rnnoise/v$version/model_version") | ||
model_url="https://media.xiph.org/rnnoise/models/rnnoise_data-$model_version.tar.gz" | ||
model_hash="$(prefetch-sri $model_url)" | ||
modelJson=pkgs/development/libraries/rnnoise/model-version.json | ||
jq --arg version "$model_version" \ | ||
--arg hash "$model_hash" \ | ||
'.version = $version | .hash = $hash' \ | ||
"$modelJson" | sponge "$modelJson" | ||
''; | ||
|
||
meta = { | ||
description = "Recurrent neural network for audio noise reduction"; | ||
homepage = "https://people.xiph.org/~jm/demo/rnnoise/"; | ||
license = licenses.bsd3; | ||
maintainers = [ maintainers.nh2 ]; | ||
license = lib.licenses.bsd3; | ||
maintainers = with lib.maintainers; [ nh2 ]; | ||
mainProgram = "rnnoise_demo"; | ||
platforms = platforms.all; | ||
platforms = lib.platforms.all; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"version": "0b50c45", | ||
"hash": "sha256-SsgcXAiE7EvVkHAmqq4WIJt7ds2df3GvWCCUovmPS0M=" | ||
} |