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

43
flake.lock generated Normal file
View File

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

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

View File

@@ -1,22 +0,0 @@
let
nixpkgs = import <nixpkgs> {};
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
];
}