Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devenv up broken with flakes #756

Closed
vesdev opened this issue Jul 27, 2023 · 15 comments
Closed

devenv up broken with flakes #756

vesdev opened this issue Jul 27, 2023 · 15 comments
Labels
bug Something isn't working

Comments

@vesdev
Copy link

vesdev commented Jul 27, 2023

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

@vesdev vesdev added the bug Something isn't working label Jul 27, 2023
@aumetra
Copy link

aumetra commented Jul 28, 2023

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 d12fb30. Everything after that broke.

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

@domenkozar
Copy link
Member

I'll look into this tomorrow.

anoadragon453 added a commit to matrix-org/synapse that referenced this issue Aug 4, 2023
Broke in #16019. This would have been caught
if someone ran 'devenv up' during manual testing of that PR, or better yet, if we had
CI for the nix developer environment.

Switch back to the latest release version, which doesn't have the upstream issue:
cachix/devenv#756
@domenkozar domenkozar pinned this issue Aug 18, 2023
@domenkozar
Copy link
Member

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

@amiuhle
Copy link

amiuhle commented Aug 23, 2023

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

anoadragon453 added a commit to matrix-org/synapse that referenced this issue Aug 23, 2023
Broke in #16019. This would have been caught
if someone ran 'devenv up' during manual testing of that PR, or better yet, if we had
CI for the nix developer environment.

Switch back to the latest release version, which doesn't have the upstream issue:
cachix/devenv#756
@fourseven
Copy link

Thanks for that suggestion @amiuhle, I was using the v0.6.3 branch through finding this issue about 2 weeks ago, but of course that was failing with dotenv and so your comment was a very helpful work-around

@alejandro-angulo
Copy link

alejandro-angulo commented Sep 17, 2023

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

"${shellPrefix shellName}devenv-up" = devenv.procfileScript;

@alejandro-angulo
Copy link

Looks like there's some issue evaluating the devenv config. I see the following error in a nix repl (hope this is helpful)

nix-repl> devShell.x86_64-linux.config.devenv
{ cliVersion = «error: error:
       … while evaluating the attribute 'value'

         at /nix/store/6s86padm2iikrwhlq8nwfv0lw9d1sbvq-source/lib/modules.nix:800:9:

          799|     in warnDeprecation opt //
          800|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          801|         inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin

         at /nix/store/6s86padm2iikrwhlq8nwfv0lw9d1sbvq-source/lib/modules.nix:800:17:

          799|     in warnDeprecation opt //
          800|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |                 ^
          801|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `devenv.cliVersion' is used but not defined.»; debug = false; dotfile = "/home/alejandro/src/alejandro-angulo/alejandr0angul0.dev/.devenv"; flakesIntegration = true; latestVersion = "0.6.3"; profile = «derivation /nix/store/yfqphhzy7b0dhpgcrn1m7d9x8avifk53-devenv-profile.drv»; root = "/home/alejandro/src/alejandro-angulo/alejandr0angul0.dev"; state = "/home/alejandro/src/alejandro-angulo/alejandr0angul0.dev/.devenv/state"; warnOnNewVersion = false; }

@jeffwkm
Copy link

jeffwkm commented Sep 20, 2023

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 {

@netbrain
Copy link

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 = ....

@zarybnicky
Copy link

When patching the flake, the second-order evaluation of procfileScript slows down devenv up by about a second on my machine, for each devenv up invocation - not a great DX improvement.

@thenonameguy
Copy link
Contributor

thenonameguy commented Nov 13, 2023

@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.

@sebnow
Copy link

sebnow commented Feb 13, 2024

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)

ereslibre added a commit to ereslibre/nixities that referenced this issue Feb 16, 2024
@arnm
Copy link

arnm commented Mar 23, 2024

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

Confirmed also works with latest v1.0 release

@domenkozar
Copy link
Member

It's now possible to use devenv with flakes, but you need to insert that devenv-up shim. It's not yet possible to use more than one shell, shall we open a separate issue for that?

@brianmay
Copy link

A separate issue sounds like a good thing to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests