2023-08-08 12:11:04 +00:00
|
|
|
{ self, clan-cli, pkgs }:
|
2023-07-20 16:07:27 +00:00
|
|
|
let
|
2023-07-26 06:29:34 +00:00
|
|
|
pythonWithDeps = pkgs.python3.withPackages (
|
2023-07-20 16:07:27 +00:00
|
|
|
ps:
|
2023-08-08 12:11:04 +00:00
|
|
|
clan-cli.propagatedBuildInputs
|
|
|
|
++ clan-cli.devDependencies
|
2023-07-20 16:07:27 +00:00
|
|
|
++ [
|
|
|
|
ps.pip
|
|
|
|
]
|
|
|
|
);
|
|
|
|
checkScript = pkgs.writeScriptBin "check" ''
|
2023-08-25 19:26:30 +00:00
|
|
|
nix build .#checks.${pkgs.system}.{treefmt,clan-pytest} -L "$@"
|
2023-07-20 16:07:27 +00:00
|
|
|
'';
|
2023-07-26 06:29:34 +00:00
|
|
|
in
|
|
|
|
pkgs.mkShell {
|
|
|
|
packages = [
|
|
|
|
pkgs.ruff
|
2023-08-03 09:29:05 +00:00
|
|
|
self.packages.${pkgs.system}.nix-unit
|
2023-07-26 06:29:34 +00:00
|
|
|
pythonWithDeps
|
|
|
|
];
|
2023-07-26 07:27:48 +00:00
|
|
|
CLAN_FLAKE = self;
|
2023-08-25 19:26:30 +00:00
|
|
|
# This is required for the python tests, where some nix libs depend on nixpkgs
|
|
|
|
CLAN_NIXPKGS = pkgs.path;
|
|
|
|
# sets up an editable install and add enty points to $PATH
|
2023-08-22 21:15:34 +00:00
|
|
|
# This provides dummy options for testing clan config and prevents it from
|
|
|
|
# evaluating the flake .#
|
|
|
|
CLAN_OPTIONS_FILE = ./clan_cli/config/jsonschema/options.json;
|
2023-07-26 06:29:34 +00:00
|
|
|
shellHook = ''
|
2023-08-26 07:25:14 +00:00
|
|
|
tmp_path=$(realpath ./.direnv)
|
2023-07-26 06:29:34 +00:00
|
|
|
repo_root=$(realpath .)
|
2023-08-26 07:25:14 +00:00
|
|
|
mkdir -p "$tmp_path/python/${pythonWithDeps.sitePackages}"
|
2023-07-20 16:07:27 +00:00
|
|
|
|
2023-07-26 06:29:34 +00:00
|
|
|
${pythonWithDeps.interpreter} -m pip install \
|
|
|
|
--quiet \
|
|
|
|
--disable-pip-version-check \
|
|
|
|
--no-index \
|
|
|
|
--no-build-isolation \
|
2023-08-26 07:25:14 +00:00
|
|
|
--prefix "$tmp_path/python" \
|
2023-07-26 06:29:34 +00:00
|
|
|
--editable $repo_root
|
2023-07-20 16:07:27 +00:00
|
|
|
|
2023-07-26 06:29:34 +00:00
|
|
|
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
2023-08-26 07:29:28 +00:00
|
|
|
export PYTHONPATH="$repo_root:$tmp_path/python/${pythonWithDeps.sitePackages}:${pythonWithDeps}/${pythonWithDeps.sitePackages}"
|
2023-07-20 23:08:11 +00:00
|
|
|
|
2023-07-26 06:29:34 +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
|
|
|
|
'';
|
|
|
|
}
|