2023-07-21 09:14:54 +00:00
|
|
|
{ pkgs ? import <nixpkgs> { }
|
|
|
|
, system ? builtins.currentSystem
|
|
|
|
,
|
|
|
|
}:
|
|
|
|
let
|
2023-07-20 15:32:28 +00:00
|
|
|
lib = pkgs.lib;
|
|
|
|
python3 = pkgs.python3;
|
|
|
|
package = import ./default.nix {
|
|
|
|
inherit lib python3;
|
|
|
|
};
|
|
|
|
pythonWithDeps = python3.withPackages (
|
|
|
|
ps:
|
2023-07-21 09:14:54 +00:00
|
|
|
package.propagatedBuildInputs
|
|
|
|
++ package.devDependencies
|
|
|
|
++ [
|
|
|
|
ps.pip
|
|
|
|
]
|
2023-07-20 15:32:28 +00:00
|
|
|
);
|
2023-07-20 16:14:33 +00:00
|
|
|
checkScript = pkgs.writeScriptBin "check" ''
|
|
|
|
nix build -f . tests.check -L "$@"
|
|
|
|
'';
|
2023-07-20 15:32:28 +00:00
|
|
|
devShell = pkgs.mkShell {
|
|
|
|
packages = [
|
|
|
|
pkgs.ruff
|
|
|
|
pythonWithDeps
|
|
|
|
];
|
|
|
|
# sets up an editable install and add enty points to $PATH
|
|
|
|
shellHook = ''
|
|
|
|
tmp_path=$(realpath ./.pythonenv)
|
|
|
|
repo_root=$(realpath .)
|
2023-07-20 23:57:39 +00:00
|
|
|
rm -rf $tmp_path
|
|
|
|
mkdir -p "$tmp_path/${pythonWithDeps.sitePackages}"
|
|
|
|
|
|
|
|
${pythonWithDeps.interpreter} -m pip install \
|
|
|
|
--quiet \
|
|
|
|
--disable-pip-version-check \
|
|
|
|
--no-index \
|
|
|
|
--no-build-isolation \
|
|
|
|
--prefix "$tmp_path" \
|
|
|
|
--editable $repo_root
|
2023-07-20 15:32:28 +00:00
|
|
|
|
2023-07-20 16:14:33 +00:00
|
|
|
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
2023-07-20 15:32:28 +00:00
|
|
|
export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2023-07-21 09:14:54 +00:00
|
|
|
devShell
|