Flake and Custom Package

Hi, I would like to add a custom python package into my flake. I’m using the following flake and the package I’m adding is chipwhisperer:

{
description = “ChipWhisperer”;
inputs.nixpkgs.url = “github:NixOS/nixpkgs/nixos-23.05”;
inputs.nixpkgs-unstable.url = “github:NixOS/nixpkgs/nixpkgs-unstable”;
inputs.flake-utils.url = “github:numtide/flake-utils”;

outputs = { self, flake-utils, nixpkgs, nixpkgs-unstable }:
flake-utils.lib.eachSystem [ flake-utils.lib.system.x86_64-linux ] (system: let
pkgs = nixpkgs.legacyPackages.${system};
pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};

  chipwhisperer = pkgs.python3Packages.buildPythonPackage rec {
      pname = "chipwhisperer";
      version = "5.7.0";
      src = pkgs.fetchPypi {
        inherit pname;
        inherit version;
        sha256 = "sha256-xTRUkdo09xKIEGITmEEHSVBd7cqrtD72lR/kklSt7Z8=";
      };
  };
  datashader = pkgs.python310Packages.datashader.overrideAttrs (old: { doChek = false; });

  #myShell = import ./shell.nix { inherit pkgs pkgsUnstable; };
  myShell = pkgs.mkShell rec {
    nativeBuildInputs = with pkgs; [
      bash
      gdb
      lcov
      pkg-config
      libffi
      gdbm
      lzma
      ncurses5
      readline63
      sqlite
      openssl
      tk
      libuuid
      zlib
      zlib-ng
      curl
      libusb1
      usbutils
      gnumake
      #avrlibc
      git
  			jupyter
  			python310
  			python310Packages.pip
  			python310Packages.bokeh
  			python310Packages.cycler
  			#python310Packages.datashader
  			python310Packages.notebook
  			python310Packages.jupyter-client
  			python310Packages.jupyter-core
  			#python310Packages.nbparameterise
  			python310Packages.pandas
  			python310Packages.holoviews
  			python310Packages.matplotlib
  			python310Packages.pyyaml
  			python310Packages.tqdm
  			python310Packages.pycryptodome
  			python310Packages.terminaltables
  			#python310Packages.phoenixAES
  			python310Packages.ipywidgets
  			python310Packages.nbconvert
  			python310Packages.numpy
      chipwhisperer
    ];
  };

in rec {
  devShells.default = myShell;
  defaultPackage = devShells.default;
});

}

If I try to build the flake.nix, I get this error:

nix develop

error: builder for ‘/nix/store/vxh1pkkhlpnk4555vz6axh6nbhb8b3zc-python3.10-chipwhisperer-5.7.0.drv’ failed with exit code 1;
last 10 log lines:
> adding ‘chipwhisperer-5.7.0.dist-info/RECORD’
> removing build/bdist.linux-x86_64/wheel
> Finished executing setuptoolsBuildPhase
> installing
> Executing pipInstallPhase
> /build/chipwhisperer-5.7.0/dist /build/chipwhisperer-5.7.0
> Processing ./chipwhisperer-5.7.0-py3-none-any.whl
> ERROR: Could not find a version that satisfies the requirement configobj (from chipwhisperer) (from versions: none)
> ERROR: No matching distribution found for configobj
>
For full logs, run ‘nix log /nix/store/vxh1pkkhlpnk4555vz6axh6nbhb8b3zc-python3.10-chipwhisperer-5.7.0.drv’.
error: 1 dependencies of derivation ‘/nix/store/nfgjcyxkhl936jahxc01fv5fr11w8i8q-nix-shell-env.drv’ failed to build

And ideas what I’m missing to make this build and essentially run chipwhisperer, like this:

import chipwhisperer as cw
scope = cw.scope()

ERROR: Could not find a version that satisfies the requirement configobj

Certainly you should add pythonPackages.configobj as an input.

Hi @AndersonTorres I solved it with the following flake, thank you:

{
description = “ChipWhisperer”;
inputs.nixpkgs.url = “github:NixOS/nixpkgs/nixos-23.05”;
inputs.nixpkgs-unstable.url = “github:NixOS/nixpkgs/nixpkgs-unstable”;
inputs.flake-utils.url = “github:numtide/flake-utils”;

outputs = { self, flake-utils, nixpkgs, nixpkgs-unstable }:
flake-utils.lib.eachSystem [ flake-utils.lib.system.x86_64-linux ] (system: let
pkgs = nixpkgs.legacyPackages.${system};
pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};

  chipwhisperer = pkgs.python3Packages.buildPythonPackage rec {
      pname = "chipwhisperer";
      version = "5.7.0";
      src = pkgs.fetchPypi {
        inherit pname;
        inherit version;
        sha256 = "sha256-xTRUkdo09xKIEGITmEEHSVBd7cqrtD72lR/kklSt7Z8=";
      };
      buildInputs = with pkgs; [
        python310Packages.configobj
        python310Packages.tqdm
        python310Packages.numpy
        python310Packages.fastdtw
        python310Packages.pyserial
        python310Packages.libusb1
        python310Packages.ecpy
        python310Packages.cython
      ];
  };
  datashader = pkgs.python310Packages.datashader.overrideAttrs (old: { doChek = false; });

  #myShell = import ./shell.nix { inherit pkgs pkgsUnstable; };
  myShell = pkgs.mkShell rec {
    nativeBuildInputs = with pkgs; [
      bash
      gdb
      lcov
      pkg-config
      libffi
      gdbm
      lzma
      ncurses5
      readline63
      sqlite
      openssl
      tk
      libuuid
      zlib
      zlib-ng
      curl
      libusb1
      usbutils
      gnumake
      #avrlibc
      git
  			jupyter
  			python310
  			python310Packages.configobj
  			python310Packages.pip
  			python310Packages.bokeh
  			python310Packages.cycler
  			#python310Packages.datashader
  			python310Packages.notebook
  			python310Packages.jupyter-client
  			python310Packages.jupyter-core
  			#python310Packages.nbparameterise
  			python310Packages.pandas
  			python310Packages.holoviews
  			python310Packages.matplotlib
  			python310Packages.pyyaml
  			python310Packages.tqdm
  			python310Packages.pycryptodome
  			python310Packages.terminaltables
  			#python310Packages.phoenixAES
  			python310Packages.ipywidgets
  			python310Packages.nbconvert
  			python310Packages.numpy
      python310Packages.fastdtw
      python310Packages.pyserial
      python310Packages.libusb1
      python310Packages.ecpy
      python310Packages.cython
      libusb1
      chipwhisperer
    ];
  };

in rec {
  devShells.default = myShell;
  defaultPackage = devShells.default;
});

}