diff --git a/pkgs/clan-cli/.envrc b/pkgs/clan-cli/.envrc index 179c25fd..c7f80b55 100644 --- a/pkgs/clan-cli/.envrc +++ b/pkgs/clan-cli/.envrc @@ -1,7 +1,7 @@ # BUG: If this is enabled the devshell depends on clan_cli building successfully # source_up -watch_file flake-module.nix default.nix +watch_file flake-module.nix shell.nix default.nix # Because we depend on nixpkgs sources, uploading to builders takes a long time use flake .#clan-cli --builders '' diff --git a/pkgs/clan-cli/shell.nix b/pkgs/clan-cli/shell.nix index f0ca91b5..1009e002 100644 --- a/pkgs/clan-cli/shell.nix +++ b/pkgs/clan-cli/shell.nix @@ -24,6 +24,7 @@ mkShell { shellHook = '' export PATH=$(pwd)/bin:$PATH + # Needed for impure tests ln -sfT ${clan-cli.nixpkgs} clan_cli/nixpkgs ''; } diff --git a/pkgs/clan-vm-manager/.envrc b/pkgs/clan-vm-manager/.envrc index 3a9c84ad..af1ef143 100644 --- a/pkgs/clan-vm-manager/.envrc +++ b/pkgs/clan-vm-manager/.envrc @@ -1,7 +1,7 @@ # See comment in clan-cli/.envrc # source_up -watch_file flake-module.nix default.nix +watch_file flake-module.nix shell.nix default.nix # Because we depend on nixpkgs sources, uploading to builders takes a long time use flake .#clan-vm-manager --builders '' diff --git a/pkgs/clan-vm-manager/default.nix b/pkgs/clan-vm-manager/default.nix index 32ec5232..1fe26b46 100644 --- a/pkgs/clan-vm-manager/default.nix +++ b/pkgs/clan-vm-manager/default.nix @@ -45,16 +45,16 @@ let runtimeDependencies = [ ]; # Dependencies required for running tests - testDependencies = - runtimeDependencies - ++ allPythonDeps - ++ [ - 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 = [ + 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; # Setup Python environment with all dependencies for running tests pythonWithTestDeps = python3.withPackages (_ps: testDependencies); @@ -114,8 +114,9 @@ python3.pkgs.buildPythonApplication rec { # Additional pass-through attributes passthru.desktop-file = desktop-file; passthru.externalPythonDeps = externalPythonDeps; - passthru.testDependencies = testDependencies; + passthru.externalTestDeps = externalTestDeps; passthru.runtimeDependencies = runtimeDependencies; + passthru.testDependencies = testDependencies; # Don't leak python packages into a devshell. # It can be very confusing if you `nix run` than load the cli from the devshell instead. diff --git a/pkgs/clan-vm-manager/shell.nix b/pkgs/clan-vm-manager/shell.nix index 48b8d10a..50a7665a 100644 --- a/pkgs/clan-vm-manager/shell.nix +++ b/pkgs/clan-vm-manager/shell.nix @@ -14,7 +14,9 @@ let devshellTestDeps = - clan-vm-manager.testDependencies + clan-vm-manager.externalPythonDeps + ++ clan-vm-manager.externalTestDeps + ++ clan-vm-manager.runtimeDependencies ++ (with python3.pkgs; [ rope mypy @@ -42,5 +44,8 @@ mkShell { shellHook = '' export PATH=$(pwd)/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 ''; }