Skip to content

Instantly share code, notes, and snippets.

@robertodr
Last active December 14, 2023 12:36
Show Gist options
  • Save robertodr/9363680a48b38a14a56aa2dddff4d348 to your computer and use it in GitHub Desktop.
Save robertodr/9363680a48b38a14a56aa2dddff4d348 to your computer and use it in GitHub Desktop.
Sample Nix flake using mach-nix
{
description = "veloxchem-hpc";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
pypi-deps-db = {
url = "github:DavHau/pypi-deps-db/a8ea7f774b76d3b61237c0bc20c97629a2248462";
flake = false;
};
mach-nix = {
url = "mach-nix/3.4.0";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.pypi-deps-db.follows = "pypi-deps-db";
};
};
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
];
};
});
}
@marcosrdac
Copy link

I had to update the pypi-deps-db commit to the last one (github:DavHau/pypi-deps-db/305b579292c8843611ef55db65ad8f4f19de7e09), but still I couldn't make this flake run with nix develop. So strange. Here is the trace:

~/tmp/python] nix develop                                                                                                                                                                      [1]
warning: updating lock file '/home/marcosrdac/tmp/python/flake.lock':
• Updated input 'pypi-deps-db':
    'github:DavHau/pypi-deps-db/a8ea7f774b76d3b61237c0bc20c97629a2248462' (2022-03-01)
  → 'github:DavHau/pypi-deps-db/305b579292c8843611ef55db65ad8f4f19de7e09' (2023-03-18)
error: builder for '/nix/store/rsfjrrsf6xgs1z1hmbgczzpd0x3hkshs-mach_nix_file.drv' failed with exit code 1;
       last 10 log lines:
       >     do()
       >   File "/nix/store/6dr20pzvf1k8y6804dw8q31nj4d7aamz-h88mkfsmnchwn89a3mbgh7d6ixy1di5l-source/mach_nix/generate.py", line 46, in do
       >     nixpkgs = NixpkgsIndex(nixpkgs_json)
       >   File "/nix/store/6dr20pzvf1k8y6804dw8q31nj4d7aamz-h88mkfsmnchwn89a3mbgh7d6ixy1di5l-source/mach_nix/data/nixpkgs.py", line 32, in __init__
       >     version = parse_ver(nix_data["version"])
       >   File "/nix/store/0zpdw7xi4c2zrc59xcz20hdi62kws3vk-python3-3.9.16-env/lib/python3.9/site-packages/packaging/version.py", line 52, in parse
       >     return Version(version)
       >   File "/nix/store/0zpdw7xi4c2zrc59xcz20hdi62kws3vk-python3-3.9.16-env/lib/python3.9/site-packages/packaging/version.py", line 197, in __init__
       >     raise InvalidVersion(f"Invalid version: '{version}'")
       > packaging.version.InvalidVersion: Invalid version: 'unstable-2022-01-20'
       For full logs, run 'nix log /nix/store/rsfjrrsf6xgs1z1hmbgczzpd0x3hkshs-mach_nix_file.drv'.

@leo60228
Copy link

leo60228 commented Apr 3, 2023

@marcosrdac packaging.versions.parse used to allow invalid versions, but this was deprecated and removed in 22.0. Nixpkgs recently updated packaging from 21.3 to 23.0.

@CodeWithOz
Copy link

@marcosrdac I'm encountering the same issue. Did you ever find a fix?

@hajlaoui-nader
Copy link

encountering the same issue, is there a workaround ? @CodeWithOz @marcosrdac

@CodeWithOz
Copy link

Nope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment