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

env not passed to lorri direnv? #83

Open
mmlb opened this issue Apr 13, 2022 · 3 comments
Open

env not passed to lorri direnv? #83

mmlb opened this issue Apr 13, 2022 · 3 comments
Assignees

Comments

@mmlb
Copy link

mmlb commented Apr 13, 2022

Describe the bug

While using direnv and cd-ing into a directory lorri fails to build due to an unfree derivation even though I have NIXPKGS_ALLOW_UNFREE=1 set.

To Reproduce
Steps to reproduce the behavior:

  1. Have an unfree package in shell.nix (in my case _1password)
  2. Try NIXPKGS_ALLOW_UNFREE=1 lorri direnv
  3. See lorri complaining about an unfree package in journalctl --user -fu lorri.service
  4. Try NIXPKGS_ALLOW_UNFREE=1 lorri watch --once
  5. Works

Expected behavior

I expected lorri direnv to see NIXPKGS_ALLOW_UNFREE=1 in the env when being run and thus correctly building my shell.nix

Metadata

[manny@zennix:~/t/lorri-bug]$ lorri info --shell-file shell.nix 
lorri version: 1.5
GC roots do not exist. Has the project been built with lorri yet?
$ uname -a
Linux zennix 5.17.1 #1-NixOS SMP PREEMPT Mon Mar 28 08:03:22 UTC 2022 x86_64 GNU/Linux

Additional context

Test shell.nix I used for the lorri info above:

let _pkgs = import <nixpkgs> { };
in { pkgs ? import (_pkgs.fetchFromGitHub {
  owner = "NixOS";
  repo = "nixpkgs";
  #branch@date: nixpkgs-unstable@2021-11-03
  rev = "a5ac0a33a70f4a0200daa517e9bdf0e39c3441df";
  sha256 = "0a30yj5xgzbhi7y240rj038jdpbrc02ff85xp7bplh4m7dr4fnhj";
}) { } }:

with pkgs;

mkShellNoCC { buildInputs = [ _1password ]; }
@mmlb
Copy link
Author

mmlb commented Apr 13, 2022

I've worked around this for now by hacking my direnvrc to:

use_nix() {
	lorri watch --once &>/dev/null
	eval "$(lorri direnv)"
}

but this is probably going to not be great (blocking direnv in the foreground?)

@mmlb
Copy link
Author

mmlb commented Apr 13, 2022

This may be less blocky

use_nix() {
	[[ ${NIXPKGS_ALLOW_UNFREE:-} == 1 ]] && lorri watch --once &>/dev/null
	eval "$(lorri direnv)"
}

@nyarly nyarly self-assigned this Jun 2, 2022
@tim-goto
Copy link

tim-goto commented Dec 6, 2024

modifying your shell.nix like this also works:

with import <nixpkgs> { config.allowUnfree = true; };
mkShell {
  nativeBuildInputs = [
    terraform
  ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants