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

Does not work well with custom options from flakes and overlays that don't evaluate but are unused #2

Closed
SuperSandro2000 opened this issue Jan 20, 2023 · 8 comments

Comments

@SuperSandro2000
Copy link
Contributor

$ RUST_BACKTRACE=1 ./target/release/nix-olde -n ~/src/nixpkgs
Fetching 'installed' ...
Fetching 'available' ...
Fetching 'repology' ...
ERROR: command ["nix-instantiate", "<nixpkgs/nixos>", "-A", "system", "-I", "nixpkgs=/home/sandro/src/nixpkgs"] failed with status: ExitStatus(unix_wait_status(256))
  stdout: ""
  stderr: "error: The option `nix.deleteChannels' d"
thread '<unnamed>' panicked at 'assertion failed: cmd.status.success()', src/main.rs:27:5
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: nix_olde::run_cmd
   4: nix_olde::get_local_installed_packages
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
ERROR: command ["nix-env", "-qa", "--json", "--arg", "config", "import <nixpkgs/pkgs/top-level/packages-config.nix>", "--option", "build-users-group", "\"\"", "-f", "/home/sandro/src/nixpkgs"] failed with status: ExitStatus(unix_wait_status(256))
  stdout: ""
  stderr: "error: attribute 'nextcloud26' missing\n\n"
thread '<unnamed>' panicked at 'assertion failed: cmd.status.success()', src/main.rs:27:5
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: nix_olde::run_cmd
   4: nix_olde::get_local_available_packages
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
... 'repology' done.
thread 'main' panicked at 'a scoped thread panicked', src/main.rs:262:8
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: std::thread::scoped::scope
   3: nix_olde::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

nextcloud26 is an entry in my overlays that does not exist yet. It would be great if such entries could be skipped.
nix.deleteChannels is an option that only exists in a flake input and then is added to the module list in the flake.nix. Can nix-instantiate be made aware of this?

@trofi
Copy link
Owner

trofi commented Jan 20, 2023

Good question. In the end we just need a .drv file that defines the whole system.

I never tried to set the system up with flakes. Looking at pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh there is a chance to use nix eval to get it. I'll try to set up a flake-based system today and get it to do something sensible.

nix-env -qa failure looks more worrying. It should already skip the overlays via config.

@SuperSandro2000
Copy link
Contributor Author

You could get the drv with nix eval /etc/nixos#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath.

@SuperSandro2000
Copy link
Contributor Author

pkgs/top-level/packages-config.nix is importing config but pkgs/top-level/impure.nix is also taking overlays as another input. Adding --arg overlays "[]" to the nix-env -qa fixes it and streams quite some json.

trofi added a commit that referenced this issue Jan 21, 2023
Prepare to extend local system derivation to inspect flakes for
#2
trofi added a commit that referenced this issue Jan 21, 2023
Will be useful for probing slakes in
#2
trofi added a commit that referenced this issue Jan 21, 2023
Use an equivalent of the below to extract system derivation:

    $ nix build --impure /etc/nixos#nixosConfigurations.$(hosname).config.system.build.toplevel --override-input nixpkgs .

Partially addresses #2
trofi added a commit that referenced this issue Jan 21, 2023
This fixes sourcing of packages for cases when flake-based system does
not define `nixpkgs` channel. I should have done it anyway to isolate
from the configuration.

Should help #2 a bit.
@trofi
Copy link
Owner

trofi commented Jan 21, 2023

Converted my system to flake configuration with impurities and removed nixos channel to break compatibility with nix-env.

I wonder if 96cade0 already makes it work for you.

Ideally packages from the overlays should be pullable as is as well (they will just fail to be found on repology, it's ok). I'll try to find flake equivalent for nix-env -qa, but meanwhile i slightly unbroke it with 533ec02.

I think the below has highest chance to succeed as it always forces nixpkgs= override whether it is present or not in default channels:

./mkrun.bash -n https://github.com/NixOS/nixpkgs/archive/refs/heads/staging.tar.gz

@trofi
Copy link
Owner

trofi commented Jan 21, 2023

With 83cfa55 I can how run ./mkrun.bash without extra parameters to get some output on flake-based system. I still use nix-env and not overriding overlays.

Can you give it a try?

@trofi
Copy link
Owner

trofi commented Jan 21, 2023

Ah, I now realized you have explicitly broken overlay and it has no way to evaluate at all, not just due to different contexts (flake vs configuration vs nixpkgs). Reproduced failure locally by adding:

--- a/overlays/local-packages.nix
+++ b/overlays/local-packages.nix
@@ -32,4 +32,6 @@ final: prev: {

   xmms2 = final.callPackage ../xmms2 {};
   xmms2_0_8 = final.callPackage ../xmms2/0.8 {};
+
+  broken_package = final.callPackage does/not/exist {};
 }

Fails as

$ ./mkrun.bash
Fetching 'installed' ...
Fetching 'repology' ...
Fetching 'available' ...
... 'available' failed.
... 'repology' failed.
... 'installed' done.
Error: MultipleErrors([Canceled("Repology fetch"), CommandFailed { cmd: ["nix-env", "-qa", "--json", "--arg", "config", "import <nixpkgs/pkgs/top-level/packages-config.nix>", "--option", "build-users-group", "\"\"", "-I", "nixpkgs=/nix/store/2z54qg6klpnp6l2gagppzwj9pinadxvp-source", "-f", "/nix/store/2z54qg6klpnp6l2gagppzwj9pinadxvp-source"], output: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "error: getting status of '/home/slyfox/.config/nixpkgs/overlays/does/not/exist': No such file or directory\n" } }])

Looking.

We will probably need to get rid of nix-env and have an equivalent code to traverse attrsets to map them to pname.

@SuperSandro2000
Copy link
Contributor Author

Yes, I didn't describe that as clear.

I removed the overlays form ~/.config/nixpkgs for now and got some results.

@trofi
Copy link
Owner

trofi commented Jan 21, 2023

I tried to filter problematic attributes with builtins.tryEval and failed: tryEval does not catch No such file or directory and can only handle throw and assert-based well behaved failures.

Let's declare working pkgs as a requirement and declare the current state good enough for flakes based systems.

@trofi trofi closed this as completed Jan 21, 2023
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

2 participants