I am writing a flake to build a Rust program I am writing which uses crane. I need it to set an environment variable to set the location of the gstreamer plugins. I’ve tried to use wrapProgram
, but it seems to produce no effect (I added dbg!
statements to the top of the Rust program to print the value of the variable.) My flake is as follows:
{
description = "A terminal music player";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.lib.${system};
aoede-crate = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.);
strictDeps = true;
nativeBuildInputs = with pkgs; [ pkg-config makeWrapper ];
propagatedBuildInputs = with pkgs.gst_all_1;
with pkgs;
[
glib
gstreamer
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gst-libav
# Add additional build inputs here
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
};
in {
checks = { my-crate = aoede-crate; };
packages.default = aoede-crate // {
installPhase = ''
wrapProgram "$out/bin/aoede" --set GST_PLUGIN_SYSTEM_PATH_1_0 "${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0"
'';
};
apps.default = flake-utils.lib.mkApp { drv = aoede-crate; };
devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};
packages = with pkgs; [ git ];
};
});
}
Any help with how to set this environment variable would be greatly appreciated!