NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.28k stars 13.54k forks source link

Bitscope tools don't seem to work #245730

Open pbek opened 1 year ago

pbek commented 1 year ago

Describe the bug

None of the Bitscope tools seem to work for me. https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/applications/science/electronics/bitscope/packages.nix

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run nix-shell -p bitscope.meter
  2. Try to run bitscope.meter (according to https://search.nixos.org/packages)
  3. See that it wasn't found.
  4. Try to run bitscope-meter-2.0.FK22G
  5. Get error message bwrap: Can't chdir to /path/you/was/in: No such file or directory

Expected behavior

The Bitscope Meter UI opens

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

I'm on today's NixOS Unstable

Notify maintainers

@vidbina, @bjornfor

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.38, NixOS, 23.11 (Tapir), 23.11.20230725.ef99fa5`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.15.1`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
bjornfor commented 1 year ago

I cannot reproduce (on NixOS/GNOME):

$ NIXPKGS_ALLOW_UNFREE=1 nix-build -A bitscope.meter && ./result/bin/bitscope-meter-2.0.FK22G
/nix/store/qznfhzfbdvw73wly3n4x0xxz1bhf64zv-bitscope-meter-2.0.FK22G
[...opens GUI just fine and no error from bwrap...]

This is on nixpkgs-unstable @ db8672b8d0a2593c2405aed0c1dfa64b2a2f428f. I also tested the reported rev (ef99fa5) and it works for me too.

pbek commented 1 year ago

Hah, thank you! Running it inside a nixpkgs folder really does work, even with nix-shell. Have you tried running it outside a nixpkgs folder?

bjornfor commented 1 year ago

Weird. It works for me no matter how I run it:

$ cd $HOME
$ /nix/store/qznfhzfbdvw73wly3n4x0xxz1bhf64zv-bitscope-meter-2.0.FK22G/bin/bitscope-meter-2.0.FK22G

$ NIXPKGS_ALLOW_UNFREE=1 NIX_PATH=nixpkgs=$HOME/nixpkgs nix-shell -p bitscope.meter --run bitscope-meter-2.0.FK22G

$ cd nixpkgs
$ NIXPKGS_ALLOW_UNFREE=1 nix-build -A bitscope.meter && ./result/bin/bitscope-meter-2.0.FK22G 

I'm on NixOS 23.05 while running the app from nixpkgs-unstable / NixOS 23.11. EDIT: But it also works when nixpkgs is checked out at my current NixOS 23.05 verison.

pbek commented 1 year ago

That's so weird, I also can use other paths, but not /etc/nixos (the path where I checked out my https://github.com/pbek/nixcfg) nor any sub-paths of that path.

Then I'll get e.g. a:

bwrap: Can't chdir to /etc/nixos: No such file or directory
bjornfor commented 1 year ago

Ok, that I can reproduce!

Looks like a general issue with buildFHSEnvBubblewrap. Maybe "nixos" should be added here, since it's a common path to have?

bjornfor commented 1 year ago

Maybe "nixos" should be added here, since it's a common path to have?

I wonder why /etc/PATH entries are listed individually instead of mapping /etc/ itself into the user env.

pbek commented 1 year ago

Ok, that I can reproduce!

Great, thank you!

Looks like a general issue with buildFHSEnvBubblewrap. Maybe "nixos" should be added here, since it's a common path to have?

Is that something I can also add to my config, or does that need discussion with the Nix community?

Do you think I should close this issue?

bjornfor commented 1 year ago

Looks like a general issue with buildFHSEnvBubblewrap. Maybe "nixos" should be added here, since it's a common path to have?

Is that something I can also add to my config, or does that need discussion with the Nix community?

There's probably a way to fixup locally, but I think it's best to patch nixpkgs (and possibly apply the patch locally if you don't want to wait for it to arrive in the channel.)

Do you think I should close this issue?

I don't have strong feelings about it. Technically, you could create a new and more generic issue about buildFHSEnvBubblewrap breaking when run from /etc/nixos, and link this one to it.

vidbina commented 1 year ago

Thanks for jumping on this @bjornfor 🙏🏿

@pbek I've cooked these up in what feels like forever ago, haven't actively fiddled with the scopes in a bit to notice and must admit I don't understand buildFHS* well enough, so I'm happy to learn from @bjornfor here.

Not an answer but I've always build stuff somewhere in my home directory ~, perhaps that approach kind of allows you to get by this issue for now (provided, I understood the issue correctly).

TL;DR: Even my nixos-config resides somewhere in ~/src. In my non-Flake days I would provide the args -I nixos="$(MY_NIXPKGS_PATH)/nixos" -I nixpkgs="$(MY_NIXPKGS_PATH)" to nixos-rebuild switch in order to not have to cd. With flakes, I haven't had to think about this at all.

Hope you're set up to probe boards soon-ish.

pbek commented 1 year ago

@bjornfor, thank you for your explanation. I'm not sure if I know enough of if to attempt to open a generic issue where I would explain the issue. @vidbina, yes, on newer installation I've my nixcfg also in my home directory, it was a coincidence that I was in that directory while testing the tools...