I have figured out how to set nixpkgs.config within a flake, but that is not quite what I need to do. I need to set nixpkgs.config.cudaSupport = true on an overlay that I am using as an input to my own flake, because that overlay includes a package that is needs CUDA. (It can build without CUDA, but will throw an exception as soon as it tries to do anything.)
My project’s flake is as follows.
{
#inputs.vs-overlay.url = "github:tadeokondrak/vs-overlay";
inputs.vs-overlay.url = "git+file:///home/aidan/src/vs-overlay?ref=vsgan";
inputs.vs-overlay.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, vs-overlay }: with nixpkgs;
let
system = "x86_64-linux";
in {
packages."${system}".default = legacyPackages.${system}.vapoursynth.withPlugins
(with vs-overlay.packages.${system}.vapoursynthPlugins; [
ffms2
vsgan
]);
};
}
I have a local fork of vs-overlay that has vsgan added. This package is the only one that needs CUDA, so I cannot simply add config.cudaSupport = true to vs-overlay, because then users could not use anything from this overlay without CUDA. Is what I need to do even possible with flakes at present? I know that there are still some limitations in flakes that prevents some developers from migrating their existing nix environments to flakes.
That now evaluates, but does not seem to be applying to vs-overlay, since pytorch reports that CUDA is unavailable. (torch.cuda.is_available() returns False in a nix shell with this flake.)
does this vs-overlay package actually provide an overlay? Seems like it should given the name. Your nixpkgs config doesn’t affect the packages you pull out of the flake because they are probably built with a different nixpkgs all together. Using the supplied overlay instead will add the packages to your nixpkgs instead. overlays is also an argument to be passed to nixpkgs during import, so assuming the flake does in fact export an overlay it would be import nixpkgs { inherit system; config.cudaSupport = true; overlays = vs-overlay.overlay; }. Then whatever packages it supplies can be pulled out of your nixpkgs instead
While the flake has overlay in the name and does indeed contain an overlay, it is not the only thing it provides. In addition to an overlay (a mechanism to extend Nixpkgs package set consistently), the flake also offers a pre-composed package set in the packages output, which applies the overlay to its own copy of Nixpkgs. And since you rely on the latter to get plug-ins, it will not see any options you instantiated your Nixpkgs with.
Now that you have added the overlay to your pkgs, you should be just able to use pkgs.vapoursynthPlugins (assuming the overlay is defined correctly in the flake).