2023-07-20 16:07:27 +00:00
|
|
|
{ pkgs ? import <nixpkgs> { }
|
|
|
|
,
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
lib = pkgs.lib;
|
|
|
|
python3 = pkgs.python3;
|
|
|
|
package = import ./default.nix {
|
|
|
|
inherit lib python3;
|
|
|
|
};
|
|
|
|
pythonWithDeps = python3.withPackages (
|
|
|
|
ps:
|
|
|
|
package.propagatedBuildInputs
|
|
|
|
++ package.devDependencies
|
|
|
|
++ [
|
|
|
|
ps.pip
|
|
|
|
]
|
|
|
|
);
|
|
|
|
checkScript = pkgs.writeScriptBin "check" ''
|
2023-07-21 11:51:49 +00:00
|
|
|
nix build -f . tests -L "$@"
|
2023-07-20 16:07:27 +00:00
|
|
|
'';
|
|
|
|
devShell = pkgs.mkShell {
|
|
|
|
packages = [
|
|
|
|
pkgs.ruff
|
|
|
|
pythonWithDeps
|
|
|
|
];
|
|
|
|
# sets up an editable install and add enty points to $PATH
|
2023-07-25 11:46:58 +00:00
|
|
|
CLAN_NIXPKGS = pkgs.path;
|
2023-07-20 16:07:27 +00:00
|
|
|
shellHook = ''
|
|
|
|
tmp_path=$(realpath ./.pythonenv)
|
|
|
|
repo_root=$(realpath .)
|
|
|
|
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
|
|
|
|
|
|
|
|
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
|
|
|
export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}"
|
2023-07-20 23:08:11 +00:00
|
|
|
|
|
|
|
export XDG_DATA_DIRS="$tmp_path/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
|
|
|
export fish_complete_path="$tmp_path/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
|
|
|
mkdir -p \
|
|
|
|
$tmp_path/share/fish/vendor_completions.d \
|
|
|
|
$tmp_path/share/bash-completion/completions \
|
|
|
|
$tmp_path/share/zsh/site-functions
|
|
|
|
register-python-argcomplete --shell fish clan > $tmp_path/share/fish/vendor_completions.d/clan.fish
|
|
|
|
register-python-argcomplete --shell bash clan > $tmp_path/share/bash-completion/completions/clan
|
2023-07-20 16:07:27 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
devShell
|