Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Using the output of a derivation as a requirements.txt? #1413

Open
YPares opened this issue Sep 4, 2024 · 1 comment
Open

[Python] Using the output of a derivation as a requirements.txt? #1413

YPares opened this issue Sep 4, 2024 · 1 comment
Labels
question Further information is requested

Comments

@YPares
Copy link

YPares commented Sep 4, 2024

To circumvent #889, I'm pre-processing some requirements.txt files with runCommand.

I've managed to do it with:

{ pkgs, ... }:

let reqs = pkgs.runCommand "genReqs" {} ''
  mkdir $out
  # Inline the imported file:
  cat ${./shared/requirements.txt} >> $out/requirements.txt
  # Remove the import:
  sed '/^-r .*/d' < ${./requirements.txt} >> $out/requirements.txt
'';
in
{
  packages = [ pkgs.stdenv pkgs.git ];

  languages.python = {
    enable = true;
    package = pkgs.python39;
    venv = {
      enable = true;
      requirements = builtins.readFile "${reqs}/requirements.txt";
    };
  };
}

but that's sort of a hack, what I'd like to do is to use the output of the derivation as the requirements. Is there a way to do this?
More generally, is it possible to parameterize devenv params from nix derivations?

@YPares YPares added the question Further information is requested label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants
@YPares and others