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

Updating darwin channel stops building #718

Closed
johnykifle opened this issue Jul 1, 2023 · 14 comments
Closed

Updating darwin channel stops building #718

johnykifle opened this issue Jul 1, 2023 · 14 comments

Comments

@johnykifle
Copy link

johnykifle commented Jul 1, 2023

After trying to to update my darwin channel with

nix-channel --update darwin

I no longer can build my configuration using darwin-rebuild switch .

###Error

error: attribute 'nixos-render-docs' missing

       at /nix/store/p5r83kdljsz507jyk2l6cb00lz7v2gsi-darwin/darwin/doc/manual/default.nix:108:29:

          107|   manpages = runCommand "darwin-manpages"
          108|     { nativeBuildInputs = [ buildPackages.nixos-render-docs ];
             |                             ^
          109|       allowedReferences = ["out"];

OS: Mac Ventura 13.4.1

NB. Am using home-manager (v 22.11) together with nix-darwin.

@StephenWithPH
Copy link

StephenWithPH commented Jul 6, 2023

It seems that recent commit 69648c6 introduced this as part of #707.

Looking around, I think this might be similar (somehow?) to #701. Of note, disabling documentation via home-manager didn't help.

Finally, I'm also using home-manager (with flakes).

(cc @emilazy)

@StephenWithPH
Copy link

Ok, setting both of the the nix-darwin options https://daiderd.com/nix-darwin/manual/index.html#opt-documentation.doc.enable and https://daiderd.com/nix-darwin/manual/index.html#opt-documentation.man.enable to false allows me to avoid the error. Of course, this is a stopgap workaround.

Those settings prevent both

manualHTML = runCommand "darwin-manual-html"
{ nativeBuildInputs = [ buildPackages.nixos-render-docs ];
and
manpages = runCommand "darwin-manpages"
{ nativeBuildInputs = [ buildPackages.nixos-render-docs ];
from breaking.

@emilazy
Copy link
Collaborator

emilazy commented Jul 6, 2023

Thanks for the report; sorry for breaking your systems!

Can I ask what nixpkgs version you are both using? Is it 22.11 (guessing from @johnykifle's Home Manager version)?

@StephenWithPH
Copy link

Can I ask what nixpkgs version you are both using? Is it 22.11

Indeed it is:

  inputs = {
    nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin";
...

@emilazy
Copy link
Collaborator

emilazy commented Jul 6, 2023

I strongly recommend updating to 23.05, as 22.11 is officially out of support for a month now and will be missing security updates imminently, if it isn't already.

However, I did try to explicitly avoid breaking things on 22.11, so I'll try to look into this further today or tomorrow. I will try to reproduce this locally but I might have to ask for details on your configuration if I can't easily achieve that. The documentation won't be able to be built regardless though, so you're not really losing anything from your workaround; with the upstream nixpkgs documentation migration, keeping compatibility with both 22.11 and supported versions wasn't feasible.

@emilazy
Copy link
Collaborator

emilazy commented Jul 6, 2023

I'm having some trouble reproducing this; when using 22.11 to build the manuals are replaced with the stubs. @StephenWithPH, are you also using Home Manager? Would it be possible to see the full inputs section of your flake and your darwinSystem call (or even better a version of your flake that has everything stripped out that doesn't contribute to seeing this behaviour)?

@emilazy
Copy link
Collaborator

emilazy commented Jul 6, 2023

Okay never mind I figured it out, will open a PR later.

@StephenWithPH
Copy link

StephenWithPH commented Jul 7, 2023

I strongly recommend updating to 23.05

I was blocked from doing so by something unrelated. That just resolved itself, so I bumped versions in flake.nix.

I didn't get the same error as before, but something still seems amiss with darwin-manual, even on 23.05:

building the system configuration...
error: builder for '/nix/store/3ypd6s5v01vyql0vjiiqmv02b79c4bdk-darwin-manual-html.drv' failed with exit code 1;
       last 10 log lines:
       >   File "/nix/store/cdlfzq1ywcx2zc9f41rlrnsr327a3vv2-python3-3.10.12/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
       >     return list(map(*args))
       >   File "/nix/store/8dc4g3160wvr4v459h4ff69xisk97q1p-nixos-render-docs-0.0/lib/python3.10/site-packages/nixos_render_docs/parallel.py", line 36, in _map_worker_step
       >     return _map_worker_fn(state[0], arg)
       >   File "/nix/store/8dc4g3160wvr4v459h4ff69xisk97q1p-nixos-render-docs-0.0/lib/python3.10/site-packages/nixos_render_docs/options.py", line 167, in _parallel_render_step
       >     return s._render_option(*a)
       >   File "/nix/store/8dc4g3160wvr4v459h4ff69xisk97q1p-nixos-render-docs-0.0/lib/python3.10/site-packages/nixos_render_docs/options.py", line 163, in _render_option
       >     raise Exception(f"Failed to render option {name}") from e
       > Exception: Failed to render option _module.args
       > """
       For full logs, run 'nix log /nix/store/3ypd6s5v01vyql0vjiiqmv02b79c4bdk-darwin-manual-html.drv'.
error: 1 dependencies of derivation '/nix/store/arbsx23rznhx00727akq38gwmzzxz987-system-applications.drv' failed to build
error: 1 dependencies of derivation '/nix/store/4v71l8zd2fig4lynipdjp0ipkiinxg4l-darwin-system-23.05.20230620.2c9ecd1+darwin4.b06bab8.drv' failed to build

The relevant output of nix log /nix/store/3ypd6s5v01vyql0vjiiqmv02b79c4bdk-darwin-manual-html.drv:

Traceback (most recent call last):
  File "/nix/store/8dc4g3160wvr4v459h4ff69xisk97q1p-nixos-render-docs-0.0/lib/python3.10/>
    return RenderedOption(option['loc'], self._convert_one(option))
  File "/nix/store/8dc4g3160wvr4v459h4ff69xisk97q1p-nixos-render-docs-0.0/lib/python3.10/>
    blocks.append(self._render_description(desc))
  File "/nix/store/8dc4g3160wvr4v459h4ff69xisk97q1p-nixos-render-docs-0.0/lib/python3.10/>
    raise RuntimeError("can't render html in the presence of docbook")
RuntimeError: can't render html in the presence of docbook

I restored the temporary fix (see below) that had worked on 22.11 to bypass the original problem, and I was able to build 23.05.

The fix for `nix-darwin':

+  documentation = {
+    doc.enable = false;
+    man.enable = false;
+  };
+

All of the above is using...

  • github:nixos/nixpkgs/nixpkgs-23.05-darwin
  • github:nix-community/home-manager/release-23.05

@StephenWithPH
Copy link

I see some breadcrumbs over in nix-community/home-manager#4142 around _module.args. I also see, @emilazy, that you're tied in with that issue. So I suspect there's a path towards eventual resolution. Thank you for your hard work on all of this!

Given nix-community/home-manager#4142 (comment), I suspect there's a chance that this is fixed in home-manager/master but the fix (if in fact it exists) has not been backported to home-manager/release-23.05.

@emilazy
Copy link
Collaborator

emilazy commented Jul 7, 2023

I'm guessing your flake looks something roughly like this:

{
  inputs.nixpkgs.url = "nixpkgs/nixpkgs-22.11-darwin";
  inputs.darwin.url = "github:LnL7/nix-darwin";
  #inputs.darwin.inputs.nixpkgs.follows = "nixpkgs";

  outputs = {self, nixpkgs, darwin}: {
    darwinConfigurations.test = darwin.lib.darwinSystem {
      system = "x86_64-darwin";
      modules = [];
      pkgs = nixpkgs.legacyPackages.x86_64-darwin;
    };
  };
}

Note the commented-out follows line. I was able to reproduce this issue with this flake and discovered something quite horrifying: if you set pkgs but nix-darwin's nixpkgs input doesn't match, it uses a horrible hybrid form where lib is taken from nix-darwin's nixpkgs input (the not-yet-released 23.11 right now) but pkgs is the argument you supplied. That meant that my version check for skipping the manual build on 22.11 wasn't firing, and is also just all kinds of terrifyingly broken in general; the Nixpkgs module system is way too tightly coupled to use completely mismatching versions of lib and pkgs. I expect that the new error you're seeing is also related to this.

You should be able to work around this more effectively, and get your manual back, by making sure nix-darwin's nixpkgs input matches the package set you're passing in. But this is a really awful bug on our end, so I'm working on a PR to fix it; it just requires disentangling a lot of assumptions about all the visible nixpkgs versions matching.

I'm not quite sure if @johnykifle is experiencing the exact same thing, as it seems easier to trigger this bug with a flakes setup, but I can imagine ways it could be happening and hopefully my fix will address that too.

@emilazy
Copy link
Collaborator

emilazy commented Jul 7, 2023

Another workaround, if you call darwinSystem with multiple different package sets, would be to supply lib as <your pkgs>.lib to darwinSystem. But also we really just need to fix this so I'll try and get a PR in sometime today.

emilazy added a commit to emilazy/nix-darwin that referenced this issue Jul 8, 2023
This should be less brittle than the version-based check, although
arguably this kind of `lib.version` mismatch should break as early
as possible...

Fixes: LnL7#718
@LnL7 LnL7 closed this as completed in 2d20e86 Jul 9, 2023
@emilazy
Copy link
Collaborator

emilazy commented Jul 9, 2023

@johnykifle @StephenWithPH, could you try updating again and seeing if this issue is resolved? It should be much harder to end up with mismatched pkgs and lib versions now and the documentation check has been made more robust.

@StephenWithPH
Copy link

could you try updating again and seeing if this issue is resolved?

@emilazy ... success! I removed the patch disabling man and docs, and everything built successfully!

Thank you for your hard work on this!

@johnykifle
Copy link
Author

@emilazy thanks for the great work.

I have actually upgraded my system to 23.05 and no issue there.

But I want to ask what's the recommended of upgrading both nix-darwin and home-manager when you use them both together?

Thanks again.

dfrankland pushed a commit to dfrankland/nix-darwin that referenced this issue Mar 2, 2024
This should be less brittle than the version-based check, although
arguably this kind of `lib.version` mismatch should break as early
as possible...

Fixes: LnL7#718
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