2023-12-14 17:47:14 +00:00
|
|
|
{ nix-unit, clan-cli, system, mkShell, writeScriptBin, openssh, ruff, python3 }:
|
2023-07-20 16:07:27 +00:00
|
|
|
let
|
2023-08-27 08:21:02 +00:00
|
|
|
checkScript = writeScriptBin "check" ''
|
|
|
|
nix build .#checks.${system}.{treefmt,clan-pytest} -L "$@"
|
2023-07-20 16:07:27 +00:00
|
|
|
'';
|
2023-10-04 09:39:22 +00:00
|
|
|
|
|
|
|
pythonWithDeps = python3.withPackages (
|
|
|
|
ps:
|
|
|
|
clan-cli.propagatedBuildInputs
|
|
|
|
++ clan-cli.devDependencies
|
|
|
|
++ [
|
|
|
|
ps.pip
|
|
|
|
]
|
|
|
|
);
|
2023-07-26 06:29:34 +00:00
|
|
|
in
|
2023-08-27 08:21:02 +00:00
|
|
|
mkShell {
|
2023-07-26 06:29:34 +00:00
|
|
|
packages = [
|
2023-08-27 08:21:02 +00:00
|
|
|
nix-unit
|
2023-09-21 15:17:48 +00:00
|
|
|
openssh
|
2023-10-04 09:39:22 +00:00
|
|
|
ruff
|
2023-10-04 08:34:32 +00:00
|
|
|
clan-cli.checkPython
|
2023-07-26 06:29:34 +00:00
|
|
|
];
|
2023-09-15 11:44:47 +00:00
|
|
|
|
2023-07-26 06:29:34 +00:00
|
|
|
shellHook = ''
|
2023-10-23 20:34:43 +00:00
|
|
|
tmp_path=$(realpath ./.direnv)
|
|
|
|
|
|
|
|
repo_root=$(realpath .)
|
|
|
|
mkdir -p "$tmp_path/python/${pythonWithDeps.sitePackages}"
|
|
|
|
|
|
|
|
# Install the package in editable mode
|
|
|
|
# This allows executing `clan` from within the dev-shell using the current
|
|
|
|
# version of the code and its dependencies.
|
|
|
|
${pythonWithDeps.interpreter} -m pip install \
|
|
|
|
--quiet \
|
|
|
|
--disable-pip-version-check \
|
|
|
|
--no-index \
|
|
|
|
--no-build-isolation \
|
|
|
|
--prefix "$tmp_path/python" \
|
|
|
|
--editable $repo_root
|
|
|
|
|
2023-11-23 14:07:08 +00:00
|
|
|
ln -sfT ${clan-cli.nixpkgs} clan_cli/nixpkgs
|
2023-10-23 20:34:43 +00:00
|
|
|
|
|
|
|
export PATH="$tmp_path/python/bin:${checkScript}/bin:$PATH"
|
|
|
|
export PYTHONPATH="$repo_root:$tmp_path/python/${pythonWithDeps.sitePackages}:"
|
2023-10-25 17:23:28 +00:00
|
|
|
|
2023-10-23 20:34:43 +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-26 06:29:34 +00:00
|
|
|
'';
|
|
|
|
}
|