diff --git a/.envrc b/.envrc index 1530103c..18a7568f 100644 --- a/.envrc +++ b/.envrc @@ -2,7 +2,7 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi -watch_file .direnv/selected-shell +watch_file .direnv/selected-shell if [ -e .direnv/selected-shell ]; then use flake .#$(cat .direnv/selected-shell) diff --git a/formatter.nix b/formatter.nix index ac96744c..1e2e1c35 100644 --- a/formatter.nix +++ b/formatter.nix @@ -10,7 +10,8 @@ treefmt.programs.mypy.enable = true; treefmt.programs.mypy.directories = { "pkgs/clan-cli".extraPythonPackages = self'.packages.clan-cli.testDependencies; - "pkgs/clan-vm-manager".extraPythonPackages = self'.packages.clan-vm-manager.testDependencies; + "pkgs/clan-vm-manager".extraPythonPackages = + self'.packages.clan-vm-manager.externalTestDeps ++ self'.packages.clan-cli.testDependencies; }; treefmt.settings.formatter.nix = { diff --git a/pkgs/clan-cli/.envrc b/pkgs/clan-cli/.envrc index c7f80b55..24d9f311 100644 --- a/pkgs/clan-cli/.envrc +++ b/pkgs/clan-cli/.envrc @@ -1,5 +1,4 @@ -# BUG: If this is enabled the devshell depends on clan_cli building successfully -# source_up +source_up watch_file flake-module.nix shell.nix default.nix diff --git a/pkgs/clan-cli/shell.nix b/pkgs/clan-cli/shell.nix index 1009e002..1daef3e6 100644 --- a/pkgs/clan-cli/shell.nix +++ b/pkgs/clan-cli/shell.nix @@ -22,9 +22,13 @@ mkShell { ] ++ devshellTestDeps; shellHook = '' - export PATH=$(pwd)/bin:$PATH + export GIT_ROOT="$(git rev-parse --show-toplevel)" + export PKG_ROOT="$GIT_ROOT/pkgs/clan-cli" + + # Add clan command to PATH + export PATH="$PKG_ROOT/bin":"$PATH" # Needed for impure tests - ln -sfT ${clan-cli.nixpkgs} clan_cli/nixpkgs + ln -sfT ${clan-cli.nixpkgs} "$PKG_ROOT/clan_cli/nixpkgs" ''; } diff --git a/pkgs/clan-vm-manager/.envrc b/pkgs/clan-vm-manager/.envrc index af1ef143..329a5f07 100644 --- a/pkgs/clan-vm-manager/.envrc +++ b/pkgs/clan-vm-manager/.envrc @@ -1,5 +1,4 @@ -# See comment in clan-cli/.envrc -# source_up +source_up watch_file flake-module.nix shell.nix default.nix diff --git a/pkgs/clan-vm-manager/default.nix b/pkgs/clan-vm-manager/default.nix index 1fe26b46..30ca3a52 100644 --- a/pkgs/clan-vm-manager/default.nix +++ b/pkgs/clan-vm-manager/default.nix @@ -45,13 +45,16 @@ let runtimeDependencies = [ ]; # Dependencies required for running tests - externalTestDeps = [ - pytest # Testing framework - pytest-cov # Generate coverage reports - pytest-subprocess # fake the real subprocess behavior to make your tests more independent. - pytest-xdist # Run tests in parallel on multiple cores - pytest-timeout # Add timeouts to your tests - ]; + externalTestDeps = + externalPythonDeps + ++ runtimeDependencies + ++ [ + pytest # Testing framework + pytest-cov # Generate coverage reports + pytest-subprocess # fake the real subprocess behavior to make your tests more independent. + pytest-xdist # Run tests in parallel on multiple cores + pytest-timeout # Add timeouts to your tests + ]; # Dependencies required for running tests testDependencies = runtimeDependencies ++ allPythonDeps ++ externalTestDeps; diff --git a/pkgs/clan-vm-manager/pyproject.toml b/pkgs/clan-vm-manager/pyproject.toml index aea2ba47..bdacae4c 100644 --- a/pkgs/clan-vm-manager/pyproject.toml +++ b/pkgs/clan-vm-manager/pyproject.toml @@ -30,6 +30,10 @@ disallow_untyped_calls = true disallow_untyped_defs = true no_implicit_optional = true +[[tool.mypy.overrides]] +module = "clan_cli.*" +ignore_missing_imports = true + [tool.ruff] target-version = "py311" line-length = 88 diff --git a/pkgs/clan-vm-manager/shell.nix b/pkgs/clan-vm-manager/shell.nix index 50a7665a..758b06eb 100644 --- a/pkgs/clan-vm-manager/shell.nix +++ b/pkgs/clan-vm-manager/shell.nix @@ -14,9 +14,7 @@ let devshellTestDeps = - clan-vm-manager.externalPythonDeps - ++ clan-vm-manager.externalTestDeps - ++ clan-vm-manager.runtimeDependencies + clan-vm-manager.externalTestDeps ++ (with python3.pkgs; [ rope mypy @@ -43,9 +41,13 @@ mkShell { ]); shellHook = '' - export PATH=$(pwd)/bin:$PATH + export GIT_ROOT=$(git rev-parse --show-toplevel) + export PKG_ROOT=$GIT_ROOT/pkgs/clan-vm-manager + + # Add clan-vm-manager command to PATH + export PATH="$PKG_ROOT/bin":"$PATH" # Add clan-cli to the python path so that we can import it without building it in nix first - export PYTHONPATH=$(pwd)/../clan-cli:$PYTHONPATH + export PYTHONPATH="$GIT_ROOT/pkgs/clan-cli":"$PYTHONPATH" ''; }