devenv
devenv copied to clipboard
Is there a way to start devenv-up of something other than the default shell?
Hi! For context I'm using devenv with flakes, here's an MRE of my situation:
{
description = "Basic MRE";
inputs = {
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
outputs = {
self,
nixpkgs,
devenv,
systems,
...
} @ inputs: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
postgresHost = "127.0.0.1";
postgresPort = 5566;
in {
packages = forEachSystem (system: {
devenv-up = self.devShells.${system}.default.config.procfileScript;
devenv-up-ci = self.devShells.${system}.ci.config.procfileScript;
});
devShells =
forEachSystem
(system: let
pkgs = import nixpkgs {inherit system;};
dbInitFile = "CREATE DATABASE db_test;";
in {
ci = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
packages = with pkgs; [
oxlint
];
languages.javascript = {
enable = true;
yarn.enable = true;
};
process = {
process-compose = pkgs.lib.mkOptionDefault {
tui = "false";
};
};
processes = {
# Start the backend...
backendApi = {
exec = "tail -f /dev/null";
process-compose = {
depends_on = {
postgres = {
condition = "process_started";
};
};
};
};
};
services.postgres = {
enable = true;
listen_addresses = postgresHost;
port = postgresPort;
initialScript = dbInitFile;
};
}
];
};
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
packages = with pkgs; [
dprint # Javascript formatter
oxlint # Javascript linter
act # run github actions locally
];
languages.javascript = {
enable = true;
yarn = {
enable = true;
};
};
services.postgres = {
enable = true;
listen_addresses = postgresHost;
port = postgresPort;
initialScript = dbInitFile;
};
}
];
};
});
};
}
How would I go about starting the services defined in the ci
shell? I tried running:
nix develop --impure .#ci --command bash -c "devenv up"
But this still runs only the postgres service thats defined in the default shell.
I also tried running:
nix run .#devenv-up-ci
But this fails with:
error:
… while evaluating the attribute 'devShells.x86_64-linux.ci.config.procfileScript'
at /nix/store/2r2766i4xifvn5s2wwysw6k9gz3d6c3i-source/flake.nix:38:9:
37| in {
38| ci = devenv.lib.mkShell {
| ^
39| inherit inputs pkgs;
… in the left operand of the update (//) operator
at /nix/store/zslv4c6fawyd1bj84a2i4x14gblz3h1w-source/flake.nix:165:24:
164| in
165| config.shell // {
| ^
166| ci = config.ciDerivation;
(stack trace truncated; use '--show-trace' to show the full trace)
error: Failed assertions:
- devenv was not able to determine the current directory.
See https://devenv.sh/guides/using-with-flakes/ how to use it with flakes.