From 92e41d2010bcac8c677f3ff1e3ed668102c6b2c6 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 4 Feb 2024 22:26:19 -0600 Subject: [PATCH] feat(nix-hm): add flake for deepfilternet --- pkgs/deepfilternet/flake.lock | 79 +++++++++++++++++++++++++++++++++++ pkgs/deepfilternet/flake.nix | 77 ++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 pkgs/deepfilternet/flake.lock create mode 100644 pkgs/deepfilternet/flake.nix diff --git a/pkgs/deepfilternet/flake.lock b/pkgs/deepfilternet/flake.lock new file mode 100644 index 00000000..2873e597 --- /dev/null +++ b/pkgs/deepfilternet/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "deepfilternet-src": { + "flake": false, + "locked": { + "lastModified": 1693481377, + "narHash": "sha256-5bYbfO1kmduNm9YV5niaaPvRIDRmPt4QOX7eKpK+sWY=", + "owner": "Rikorose", + "repo": "DeepFilterNet", + "rev": "978576aa8400552a4ce9730838c635aa30db5e61", + "type": "github" + }, + "original": { + "owner": "Rikorose", + "repo": "DeepFilterNet", + "rev": "978576aa8400552a4ce9730838c635aa30db5e61", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1706925685, + "narHash": "sha256-hVInjWMmgH4yZgA4ZtbgJM1qEAel72SYhP5nOWX4UIM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "79a13f1437e149dc7be2d1290c74d378dad60814", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "deepfilternet-src": "deepfilternet-src", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/pkgs/deepfilternet/flake.nix b/pkgs/deepfilternet/flake.nix new file mode 100644 index 00000000..c939c034 --- /dev/null +++ b/pkgs/deepfilternet/flake.nix @@ -0,0 +1,77 @@ +{ + description = "Flake for deepfilternet, a noise supression algorithm."; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + deepfilternet-src = { + flake = false; + url = + "github:Rikorose/DeepFilterNet?rev=978576aa8400552a4ce9730838c635aa30db5e61"; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, deepfilternet-src }: + flake-utils.lib.eachDefaultSystem (system: + let + lib = nixpkgs.lib; + pkgs = nixpkgs.legacyPackages.${system}; + rust-toolchain = pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = with pkgs; [ rustc cargo ]; + }; + in rec { + packages.default = pkgs.rustPlatform.buildRustPackage rec { + pname = "deepfilternet"; + version = "0.5.6"; + src = "${deepfilternet-src}"; + cargoLock = { + lockFile = "${deepfilternet-src}/Cargo.lock"; + allowBuiltinFetchGit = true; + }; + buildInputs = with pkgs; [ ladspaH ]; + buildAndTestSubdir = "ladspa"; + postInstall = '' + mkdir $out/lib/ladspa + mv $out/lib/libdeep_filter_ladspa.so $out/lib/ladspa/libdeep_filter_ladspa.so + ''; + meta = { + description = "Noise supression using deep filtering"; + homepage = "https://github.com/Rikorose/DeepFilterNet"; + license = with lib.licenses; [ mit asl20 ]; + changelog = + "https://github.com/Rikorose/DeepFilterNet/releases/tag/${src.rev}"; + }; + }; + }) // { + overlays.default = final: prev: { + deepfilternet = self.packages.${final.system}.default; + easyeffects = let + pkgs = final.pkgs; + lib = pkgs.lib; + in prev.easyeffects.overrideAttrs (oldAttrs: { + buildInputs = with pkgs; [ deepfilternet ] ++ oldAttrs.buildInputs; + preFixup = let + lv2Plugins = with pkgs; [ + calf # compressor exciter, bass enhancer and others + lsp-plugins # delay, limiter, multiband compressor + mda_lv2 # loudness + zam-plugins # maximizer + ]; + ladspaPlugins = with pkgs; [ + deepfilternet + rubberband # pitch shifting + ]; + in '' + gappsWrapperArgs+=( + --set LV2_PATH "${lib.makeSearchPath "lib/lv2" lv2Plugins}" + --set LADSPA_PATH "${ + lib.makeSearchPath "lib/ladspa" ladspaPlugins + }" + ) + ''; + }); + }; + + }; +}