devenv: devenv up broken with flakes

Describe the bug devenv up not working with flakes

To reproduce use example flake in the guides and run devenv up https://devenv.sh/guides/using-with-flakes/#modifying-your-flakenix-file

gives the error

error: flake does not provide attribute 'packages.x86_64-linux.devenv-up', 'legacyPackages.x86_64-linux.devenv-up' or 'devenv-up'

Version devenv: 0.6.3

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 35
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

github:cachix/devenv/6a30b674fb5a54eff8c422cc7840257227e0ead2 is also working for me, with dotenv integration

You can workaround it for now by using revision github:cachix/devenv/9ba9e3b908a12ddc6c43f88c52f2bf3c1d1e82c1 as an input.

@zarybnicky I circumvent this with process-compose via this enterShell snippet:

# symlinking latest templated process-compose yaml file from config.processes
ln -sf ${config.process-managers.process-compose.configFile} ${config.env.DEVENV_ROOT}/process-compose.yml

and gitignoring the symlinked file. This way I can just use the plain process-compose up with all the convenience of config.processes and direnv caching.

The suggested commits didn’t work for me since I was using some newer options. I ended up adding the following to my flake as a workaround: packages.devenv-up = self.devShell.${system}.config.procfileScript;

Thanks, got this to fix my config too.

Added devenv-up as a flake output in context:

outputs = { self, nixpkgs, devenv, systems, ... }@inputs:
    let forEachSystem = nixpkgs.lib.genAttrs (import systems);
    in {
      devenv-up = self.devShells.x86_64-linux.default.config.procfileScript;

      devShells = forEachSystem (system: {
        default = devenv.lib.mkShell {

Did some analysis based on the Git history of src/devenv-devShell.nix

The last commit in the history of that file that worked was d12fb308ef41e693dd3142c7d16af21809bbc948. Everything after that broke.

So we can conclude that commit ddba5b442488a0036bba88097b9048d83dd0e709 broke the devenv up with flakes.
And indeed, if I use the commit just before the commit in question, 1e4701fb1f51f8e6fe3b0318fc2b80aed0761914, the example starts working again.

Using the default flake template for devenv i had to add the following to my flake.nix

packages = forEachSystem (system: {
  devenv-up = self.devShells.${system}.default.config.procfileScript;
});

as a sibling of

devShells = ....

I’ll look into this tomorrow.

The workarounds and implementation use the procfileScript from the default devShell. Are multiple devShells not supported, or am I incorrect in assuming that the procfileScript of the respective devShell would need to be used?

For instance I have a default shell with basic tooling, and another devShell which sets up processes. Having applied the workaround, when I nix develop .#second-shell --impure I get the message:

No 'processes' option defined: https://devenv.sh/processes/
Minimal reproducible example

flake.nix

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
    systems.url = "github:nix-systems/default";
    devenv.url = "github:cachix/devenv";
  };

  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);
    in
    {
      packages = forEachSystem (system: {
        devenv-up = self.devShells.${system}.default.config.procfileScript;
      });

      devShells = forEachSystem
        (system:
          let
            pkgs = nixpkgs.legacyPackages.${system};
          in
          {
            default = devenv.lib.mkShell {
              inherit inputs pkgs;
              modules = [ { packages = [ pkgs.cowsay ]; }
              ];
            };
            second-shell = devenv.lib.mkShell {
              inherit inputs pkgs;
              modules = [ {
                  packages = [ pkgs.hello ];

                  enterShell = ''
                    hello
                  '';

                  processes.run.exec = "hello";
                }
              ];
            };
          });
    };
}

Actual Output

$ nix develop .#second-shell --impure
Hello, world!
$ devenv up
No 'processes' option defined: https://devenv.sh/processes/

Expected Output

$ devenv up
12:10:31 system | run.1 started (pid=281814)
12:10:31 run.1  | Hello, world!
12:10:31 system | run.1 stopped (rc=0)

The suggested commits didn’t work for me since I was using some newer options. I ended up adding the following to my flake as a workaround: packages.devenv-up = self.devShell.${system}.config.procfileScript;

basically I’m manually doing this https://github.com/cachix/devenv/blob/63d20fe09aa09060ea9ec9bb6d582c025402ba15/flake-module.nix#L51