Python environments (mach-nix)

Hello,

I’m trying to configure a flake to manage my python environments.
here’s my flake:

{
  description = "veloxchem-hpc";
  inputs = {
    #nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    pypi-deps-db = {
      url = "github:DavHau/pypi-deps-db";
      flake = false;
    };
    mach-nix = {
      url = "github:DavHau/mach-nix/3.5.0";
      inputs.pypi-deps-db.follows = "pypi-deps-db";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, flake-utils, mach-nix, pypi-deps-db }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        pythonEnv = mach-nix.lib."${system}".mkPython {
          requirements = builtins.readFile ./requirements.txt + ''
            # additional dependencies for local work
            jupyterlab
            pandas
          '';
        };
      in
      {
        devShell = pkgs.mkShell {
          nativeBuildInputs = [ ];
          buildInputs = [
            pythonEnv
          ];
        };
      });
}

This flake encounters an error:

error: The pypiDataRev seems to be older than the nixpkgs which is currently used.
       Because of this, mach-nix might lack dependency information for some python packages in nixpkgs.
       This can degrade the quality of the generated environment or result in failing builds.
       It is recommended to pass a newer pypiDataRev to mach-nix during import.
       For flakes users: Update the `pypi-deps-db` input of mach-nix.
       You can ignore this error by passing 'ignoreDataOutdated = true' to mk* or build* functions

the error cause is clear, is there any workaround ? if not, is there a new alternative to mach-nix ?

Thank you !

Does the ignore option cited in the error ~work?

I tried it. It doesn’t work.

Exemplars - or just use boil-in-bag

1 Like

IIRC the last rev db has been published sometime this fall, at least on dav’s repo, and they’ve put up a message that we’ll need to DIY new ones along w/ some instructions for how we can generate our own, but I imagine it’s also possible to piggyback on someone else’s fork.

We have a run-able VeloxChem here: https://github.com/Nix-QChem/NixOS-QChem/blob/65b0f05d88af18beebc1cdbf85ba181a200a2eb6/pkgs/apps/veloxchem/default.nix

Could maybe need some updates, but should work.

the error cause is clear, is there any workaround ? if not, is there a new alternative to mach-nix ?

Shameless plug, but you might want to consider Introduction - Pyproject.nix.

the example pyproject.toml - Pyproject.nix results in

nix build path:.

error: builder for '/nix/store/7ihrim8v1bh36swvi88xf1sawm2bzwzz-python3.10-spam-2020.0.0.drv' failed with exit code 1;
       last 10 log lines:
       >   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
       >   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
       >   File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
       >   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
       >   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
       >   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
       >   File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
       > ModuleNotFoundError: No module named 'setuptools'
       >
       > ERROR Backend 'setuptools.build_meta:__legacy__' is not available.
       For full logs, run 'nix log /nix/store/7ihrim8v1bh36swvi88xf1sawm2bzwzz-python3.10-spam-2020.0.0.drv'.

I had neglected to implement the fallback behaviour described in pyproject.toml - pip documentation v24.0, but that’s on master now.