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

shellHook runs twice for nom develop #140

Open
amuricys opened this issue Jul 8, 2024 · 3 comments
Open

shellHook runs twice for nom develop #140

amuricys opened this issue Jul 8, 2024 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@amuricys
Copy link

amuricys commented Jul 8, 2024

parts of it run twice immediately upon entering the shell, like the cp command below. I know this because the second attempt at copying from the flake below fails with "permission denied" (because the file is not writable, since it comes from the nix store). i know this is ugly (copying files from the store to the home directory, it's just for illustration purposes).

{
  description = "hey";

  inputs = {
    nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
    flake-utils.url = github:numtide/flake-utils;
  };

  outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachSystem [ "aarch64-darwin" ] (system:
      let
        pkgs = import nixpkgs { inherit system; };
      in
      {
        devShell = pkgs.mkShell {
          src = [ ./. ];
          packages = [ pkgs.hello ];
          shellHook = ''
            cp ${hello}/bin/hello .
            whoami
          '';
        };
      });
}

the output is

nom develop
warning: Git tree '/Users/deco/work/banksy' is dirty
copying path '/nix/store/566f5isbvw014h7knmzmxa5l6hshx43k-hello-2.12.1' from 'https://cache.nixos.org'
nix-shell-env> building '/nix/store/ipdk9liiaglzgjarf06bzrmc5fhpf15a-nix-shell-env.drv'

warning: Git tree '/Users/deco/work/' is dirty
cp: cannot create regular file './hello': Permission denied
deco
(nix:nix-shell-env) H2TYHFDQD7: deco$ # press Ctrl-D
exit
deco

nix develop works as expected.

@maralorn
Copy link
Owner

maralorn commented Jul 8, 2024

Yes, this is a known limitation. From the readme:

The latter two commands work by calling nix shell or nix develop twice, the first time with overridden --run exit and monitoring the output, the second time passing output through to the user. This will incur a performance cost by doubling eval time.

@amuricys
Copy link
Author

sorry for missing that! Feel free to close the issue :)

@maralorn
Copy link
Owner

Well, I agree that this is super annoying and I would love a better solution. So lets keep this open in the hope that someone suggests a fix!

@maralorn maralorn added enhancement New feature or request help wanted Extra attention is needed labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants