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

environment with local poetry project #527

Open
rokroskar opened this issue Dec 5, 2022 · 0 comments
Open

environment with local poetry project #527

rokroskar opened this issue Dec 5, 2022 · 0 comments

Comments

@rokroskar
Copy link
Contributor

rokroskar commented Dec 5, 2022

I'm trying to build a python environment with mach-nix where one of the packages I would like in the environment is a local poetry-based project. What's the best way to go about this? I've tried something like

{ pkgs, ... }:
let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix";
    ref = "refs/tags/3.5.0";
  }) { };
  python-packages = mach-nix.mkPython {
    requirements = ''
      <requirements one per line>
    '';
    };
    packagesExtra = [ mach-nix.buildPythonPackage ./path/to/project ];
  };
in
{}

but mach-nix doesn't seem to be happy with that, yielding

...
       at /nix/store/n6hsk44fw5x8kqkff2mxyd5wd6663ai5-source/mach_nix/nix/lib.nix:229:14:

          228|         Please manually specify '${for_attr}' '';
          229|       data = extract python src error_msg;
             |              ^
          230|       result = if hasAttr attr data then data."${attr}" else throw error_msg;

       … while evaluating 'extract'

       at /nix/store/n6hsk44fw5x8kqkff2mxyd5wd6663ai5-source/mach_nix/nix/lib.nix:198:28:

          197|
          198|     extract = python: src: fail_msg:
             |                            ^
          199|     let

       … while realising the context of a path

       at /nix/store/n6hsk44fw5x8kqkff2mxyd5wd6663ai5-source/mach_nix/nix/lib.nix:205:10:

          204|     in
          205|       if pathExists file_path then fromJSON (builtins.unsafeDiscardStringContext (readFile file_path)) else throw fail_msg;
             |          ^
          206|

       … while evaluating the attribute 'src' of the derivation 'package-requirements'

       at /nix/store/5n402azp0s9vza4rziv4z5y88v2cv1mq-nixpkgs/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let
       cannot coerce a function to a string

       at /nix/store/n6hsk44fw5x8kqkff2mxyd5wd6663ai5-source/lib/extractor/default.nix:156:14:

          155|     stdenv.mkDerivation ( (base_derivation []) // {
          156|       inherit src;
             |              ^
          157|       name = "package-requirements";

However, if I simply include the project directly in the top-level requirementsfrom pypi and then the derivation works. Ideally I would like to install it from local source...

Hints much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant