Poetry2nix environment missing gcc compilation dependency

Total beginner with nix but I thought I would give it a try with a small python/snakemake environment (what a mistake! I ended up in the rabbit hole of nix and python packages…).

So I have already dodged some issues with setuptools missing with the recommended overlay in poetry2nix. However I stumble on another issue linked to the compilation of one of the python package that requires gsl.
UserWarning: Error occured getting GSL path config: [Errno 2] No such file or directory: 'gsl-config'

Here is my flake.nix

{
  description = "poetry2nix env";

  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.poetry2nix = {
    url = "github:nix-community/poetry2nix";
    inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, flake-utils, poetry2nix }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        # see https://github.com/nix-community/poetry2nix/tree/master#api for more functions
        ↪ and examples.
        # inherit (poetry2nix.legacyPackages.${system}) mkPoetryApplication;
        pkgs = nixpkgs.legacyPackages.${system};
        p2n = poetry2nix.legacyPackages.${system};

        pypkgs-build-requirements = {
          newick = [ "setuptools" ];
          demes = [ "setuptools" ];
          tskit = [ "setuptools" ];
          msprime = [ "setuptools" ];
        };
        p2n-overrides = p2n.defaultPoetryOverrides.extend (self: super:
          builtins.mapAttrs (package: build-requirements:
            (builtins.getAttr package super).overridePythonAttrs (old: {
              buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.
              ↪ isString pkg then builtins.getAttr pkg super else pkg) build-requirements);
            })
          ) pypkgs-build-requirements
        );

        pythonEnv = p2n.mkPoetryEnv {
          projectDir = ./.;
          overrides = p2n-overrides;
        };
      in
      {
        # packages = {
        #   myapp = mkPoetryApplication { projectDir = self; };
        #   default = self.packages.${system}.myapp;
        # };

        devShells.default = pkgs.mkShell {
          packages = [
#            pkgs.gsl
            pkgs.python310
            pkgs.snakemake
            poetry2nix.packages.${system}.poetry
            pythonEnv
          ];
        };
      });
}

The poetry file is pretty simple and only contains msprime as a dependency.

I’d be grateful for any pointer on where I’m supposed to indicate I need gsl in the build process. More generally how does one go about indicating c++ libraries needed for a build for instance.

Thanks

I am thoroughly out of my depth here, but I’m attempting to learn Nix and recently came across an explanation I think answers your question. I read that overrides allows you to customize what is passed into a derivation, and overrideAttrs allows you to customize how the derivation is built. Based on that info, it would seem you’d need to pass gsl into overrides…?

I can’t even find the link right now…I think it was a Stack Overflow answer. I will post here if/when I find it.

Thanks, I think I get the concept but totally lost on the realization. I tried to add gsl in addition to the setuptools but this did not work as I think it’s only for python packages.

ah I think this was as simple as adding pkgs.gsl but not as a string in the override
msprime = [ "setuptools" pkgs.gsl ];

Although I now have a different error with dependency version requirements which is weird.

ERROR: Could not find a version that satisfies the requirement demes>=0.2 (from msprime) (from versions: none)
ERROR: No matching distribution found for demes>=0.2