From f05ddf8fcd5cebf044173d8b595dfb424e529a42 Mon Sep 17 00:00:00 2001 From: ChronosXYZ Date: Sun, 24 Mar 2024 05:13:12 +0300 Subject: [PATCH] Add Nix flake for the project (#232) * Add Nix flake for the project * Add `codec2` library for M17 encoding support --- .gitignore | 3 ++- flake.lock | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 18 +++++++++++++++ package.nix | 46 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix diff --git a/.gitignore b/.gitignore index 19e7350..3327894 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ examples *.bin *.ans *.patch -*.zip \ No newline at end of file +*.zip +result \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f21694b --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711163522, + "narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bc9e9c3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,18 @@ +{ + description = "Digital Speech Decoder - Florida Man Edition "; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + perSystem = { config, pkgs, ... }: { + packages.default = config.packages.dsd-fme; + + packages.dsd-fme = pkgs.callPackage ./package.nix { }; + }; + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..ea1bd76 --- /dev/null +++ b/package.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, cmake +, mbelib +, libsndfile +, ncurses +, pulseaudio +, rtl-sdr +, itpp +, codec2 +, portaudioSupport ? true +, portaudio ? null +}: + +assert portaudioSupport -> portaudio != null; + +stdenv.mkDerivation { + name = "dsd-fme"; + + src = ./.; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ + mbelib + libsndfile + itpp + rtl-sdr + ncurses.dev + pulseaudio.dev + codec2 + ] ++ lib.optionals portaudioSupport [ portaudio ]; + + doCheck = true; + + meta = with lib; { + description = "Digital Speech Decoder - Florida Man Edition"; + longDescription = '' + DSD is able to decode several digital voice formats from discriminator + tap audio and synthesize the decoded speech. Speech synthesis requires + mbelib, which is a separate package. + ''; + homepage = "https://github.com/szechyjs/dsd"; + license = licenses.mit; + platforms = platforms.unix; + }; +}