mach-nix icon indicating copy to clipboard operation
mach-nix copied to clipboard

Pinned awscli breaks environment

Open mausch opened this issue 3 years ago • 3 comments

Given this shell.nix:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/3.5.0";
  }) {};
  pythonEnv = mach-nix.mkPython {
    requirements = ''
      datadog==0.10.0
      setuptools # otherwise we get ModuleNotFoundError: No module named 'pkg_resources'
    '';
  };
in
mach-nix.nixpkgs.mkShell {
  buildInputs = [
    # This works:
    # mach-nix.nixpkgs.awscli

    # This returns "ModuleNotFoundError: No module named 'datadog'"
    (import (fetchTarball https://github.com/NixOS/nixpkgs/archive/b09c989b82f7a4f7319802a1dcf8bfe859d65362.tar.gz) {}).awscli

    pythonEnv
  ];
}

Running the following:

nix-shell --run "python -c 'import datadog'"

breaks with the pinned awscli but works when using awscli from the nixpkgs in mach-nix.

mausch avatar Jul 12 '22 09:07 mausch

your older awscli is injecting a python 3.8 into the environment, and 'python' then refers to that. If you run 'python3.9' in the 'pinned' variant, you can import datadog.

I suppose it's an issue of shadowing.

TyberiusPrime avatar Jul 12 '22 10:07 TyberiusPrime

Hmm I thought nix took care of wrapping whatever Python interpreter was necessary for each application?

mausch avatar Jul 12 '22 10:07 mausch

Ran into this as well. Is there a way to override which python is the default for the command?

@mausch I tried mach-nix.nixpkgs.awscli2 but that errored for me. (error: attribute 'nixpkgs' missing)

blissdev avatar Aug 11 '22 17:08 blissdev