use nix flake & remove legacy shell.nix

This commit is contained in:
2020-11-30 17:59:52 +01:00
parent 1f57a5489d
commit 133196f3cd
3 changed files with 113 additions and 22 deletions

70
flake.nix Normal file
View File

@@ -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
];
};
};
}