Hi! I’m trying to install the python package pymc. It has a nix package available but when installing it, it tries to download 8Gb of data and install 15Gb of data while dropping my pc to its knees (I don’t have a very beefy pc but I have installed this library in much smaller computers). Problem is the derivation tries to install additional dependencies like dm-haiku which is a ML library which I don’t need. To solve this I want to install a custom derivation to see if I can tinker the dependencies to the minimum. Here’s what I’ve got:
devShells = forEachSupportedSystem ({ pkgs }:
let
concatMajorMinor = v:
pkgs.lib.pipe v [
pkgs.lib.versions.splitVersion
(pkgs.lib.sublist 0 2)
pkgs.lib.concatStrings
];
python = pkgs."python${concatMajorMinor version}";
pymcLocal = ps: ps.callPackage ./pymc.nix {};
myPython = python.withPackages(ps: with ps; [
(pymcLocal ps)
]);
sysPkgs = with pkgs; [
go
pkg-config
pyright
gotools
gopls
pgadmin4
golangci-lint
];
pythonPkgs = with myPython.pkgs; [
venvShellHook
pip
numpy
pandas
seaborn
psycopg2
cvxpy
pymcLocal
];
in
{
default = pkgs.mkShell {
venvDir = ".venv";
postShellHook = ''
# UV_PYTHON_DOWNLOADS=never
echo "INIT PYENV..."
echo $(which python)
source ./venv/bin/activate
'';
packages = sysPkgs ++ pythonPkgs;
};
});
I have a flake.nix which builds the shell and tries to install the pymc package, I’m following the wiki here but I don’t know if I’m doing it correctly
Here’s pymc.nix which is only a copy paste from the nixpkgs repo:
{
lib,
buildPythonPackage,
fetchFromGitHub,
# build-system
setuptools,
versioneer,
# dependencies
arviz,
cachetools,
cloudpickle,
numpy,
pandas,
pytensor,
rich,
scipy,
threadpoolctl,
typing-extensions,
}:
buildPythonPackage rec {
pname = "pymc";
version = "5.25.1";
pyproject = true;
src = fetchFromGitHub {
owner = "pymc-devs";
repo = "pymc";
tag = "v${version}";
hash = "sha256-zh6FsCEviuyqapguTrUDsWKq70ef0IKRhnn2dkgQ/KA=";
};
build-system = [
setuptools
versioneer
];
pythonRelaxDeps = [
"pytensor"
];
dependencies = [
arviz
cachetools
cloudpickle
numpy
pandas
pytensor
rich
scipy
threadpoolctl
typing-extensions
];
# The test suite is computationally intensive and test failures are not
# indicative for package usability hence tests are disabled by default.
doCheck = false;
pythonImportsCheck = [ "pymc" ];
meta = {
description = "Bayesian estimation, particularly using Markov chain Monte Carlo (MCMC)";
homepage = "https://github.com/pymc-devs/pymc";
changelog = "https://github.com/pymc-devs/pymc/releases/tag/v${version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
nidabdella
ferrine
];
};
}
This errors out with:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:37:12:
36|
37| strict = derivationStrict drvAttrs;
| ^
38|
… while evaluating derivation 'nix-shell'
whose name attribute is located at /nix/store/3abvz230bn897gbja4y653jx152m9fqw-source/pkgs/stdenv/generic/make-derivation.nix:482:13
… while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
at /nix/store/3abvz230bn897gbja4y653jx152m9fqw-source/pkgs/stdenv/generic/make-derivation.nix:534:13:
533| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
534| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
535| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: Dependency is not of a valid type: element 15 of nativeBuildInputs for nix-shell
Running --show-trace provides no useful extra info,
Any help is appreciated!