diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ef52abb --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "import-cargo": { + "locked": { + "lastModified": 1594305518, + "narHash": "sha256-frtArgN42rSaEcEOYWg8sVPMUK+Zgch3c+wejcpX3DY=", + "owner": "edolstra", + "repo": "import-cargo", + "rev": "25d40be4a73d40a2572e0cc233b83253554f06c5", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "import-cargo", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1606667422, + "narHash": "sha256-NhCeG6NpetMWkflygIn6vHipuxFbrKzlFScr8+PONYQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3c72bb875e67ad1bce805fe26a8a5d3a0e8078ed", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-20.09", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "import-cargo": "import-cargo", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..17e9646 --- /dev/null +++ b/flake.nix @@ -0,0 +1,70 @@ +{ + description = "Converts audio files"; + + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-20.09; + import-cargo.url = github:edolstra/import-cargo; + }; + + outputs = { self, nixpkgs, import-cargo }: + let + inherit (import-cargo.builders) importCargo; + in { + defaultPackage.x86_64-linux = + with import nixpkgs { system = "x86_64-linux"; }; + stdenv.mkDerivation { + name = "audio-conv"; + src = self; + + nativeBuildInputs = [ + # setupHook which makes sure that a CARGO_HOME with vendored dependencies + # exists + (importCargo { lockFile = ./Cargo.lock; inherit pkgs; }).cargoHome + + # Build-time dependencies + cargo + rustc + pkg-config + ]; + + buildInputs = [ + gst_all_1.gstreamer + + # needed for opus, resample, ... + gst_all_1.gst-plugins-base + + # needed for flac + gst_all_1.gst-plugins-good + ]; + + buildPhase = '' + cargo build --release --offline + ''; + + installPhase = '' + install -Dm775 ./target/release/audio-conv $out/bin/audio-conv + ''; + }; + + devShell.x86_64-linux = + with import nixpkgs { system = "x86_64-linux"; }; + stdenv.mkDerivation { + name = "audio-conv"; + buildInputs = [ + cargo + rustc + rustfmt + rust-analyzer + + pkg-config + gst_all_1.gstreamer + + # needed for opus, resample, ... + gst_all_1.gst-plugins-base + + # needed for flac + gst_all_1.gst-plugins-good + ]; + }; + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 65289d9..0000000 --- a/shell.nix +++ /dev/null @@ -1,22 +0,0 @@ -let - nixpkgs = import {}; -in - with nixpkgs; - stdenv.mkDerivation { - name = "audio-conv"; - buildInputs = [ - cargo - rustc - rustfmt - rust-analyzer - - pkg-config - gst_all_1.gstreamer - - # needed for opus, resample, ... - gst_all_1.gst-plugins-base - - # needed for flac - gst_all_1.gst-plugins-good - ]; - }