nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.05k stars 1.82k forks source link

bug: Build fails while converting to DocBook #3680

Closed dinkopehar closed 1 year ago

dinkopehar commented 1 year ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I have my dotfiles managed by darwin-nix which uses home-manager. I've updated the nix channels using nix-channel --update but it broke some of the things. I've disabled some of the packages that maybe require some new tweaks to work, but it still fails.

I'm not sure if this is related to Nix or Home-Manager. It seems like it's trying to build some manual-combined/ docbook for fish completions, but it fails:

building '/nix/store/n2902q6psifm4a8yxa683pslsjjczv4r-ytmdl-2022.03.16-fish-completions.drv'...
building '/nix/store/z01252wp181mhql8qlm5ip383afli4xd-zplug-2.4.2-fish-completions.drv'...
building '/nix/store/sh0pf5jkgrxph0fsp91dmk9ww80mki1k-zulu17.34.19-ca-jdk-17.0.3-fish-completions.drv'...
building '/nix/store/vblq2zbhim4yr35sw6556i8jwahlc10q-crystal-1.2.2-fish-completions.drv'...
building '/nix/store/h21xbs4v3qizz1s2y0zmjnmg1kvr2nll-converted-asciidoc.drv'...
building '/nix/store/244lsgm43kbikp37m9phh7gk0h1j1xpd-options.json.drv'...
building '/nix/store/nwpw9fmmn4ffp5yg15j7605i8a8c1bnr-options.json.drv'...
Converting contributing.adoc to DocBook ...
building '/nix/store/v4kia3n7hz99n3780jc880a9bnh1yalg-options-db.xml.drv'...
building '/nix/store/zsvw23xq1sfr0wc68avyq76w0vigvzfw-options-db.xml.drv'...
building '/nix/store/3sg8ra9bbjs5cacqvphk3dxavc9aw2kb-options-db.xml.drv'...
Converting faq.adoc to DocBook ...
Converting installation.adoc to DocBook ...
Converting nix-flakes.adoc to DocBook ...
Converting usage.adoc to DocBook ...
Converting writing-modules.adoc to DocBook ...
Converting release-notes/release-notes.adoc to DocBook ...
Converting release-notes/rl-1809.adoc to DocBook ...
Converting release-notes/rl-1903.adoc to DocBook ...
Converting release-notes/rl-1909.adoc to DocBook ...
Converting release-notes/rl-2003.adoc to DocBook ...
Converting release-notes/rl-2009.adoc to DocBook ...
Converting release-notes/rl-2105.adoc to DocBook ...
Converting release-notes/rl-2111.adoc to DocBook ...
Converting release-notes/rl-2205.adoc to DocBook ...
Converting release-notes/rl-2211.adoc to DocBook ...
Converting release-notes/rl-2305.adoc to DocBook ...
building '/nix/store/n3ap8bmx7bdi8kr1cjlmvfl3wxn9hzzw-nmd-documents.drv'...
created 42 symlinks in user environment
building '/nix/store/zvjbxmv90w44cdq501lc5jnbl2f8sw2w-manual-combined.drv'...

/nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml:1389: element variablelist: Relax-NG validity error : Did not expect element variablelist there
  1385  </section>
  1386  </chapter>
  1387   <appendix xml:id="ch-options">
  1388    <title>Configuration Options</title>
  1389    <variablelist xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="home-manager-options" xml:base="nmd-result/home-manager-options.xml"><varlistentry><term xlink:href="#opt-_module.args" xml:id="opt-_module.args"><option>_module.args</option></term><listitem><simpara>Additional arguments passed to each module in addition to ones
  1390  like <literal>lib</literal>, <literal>config</literal>,
  1391  and <literal>pkgs</literal>, <literal>modulesPath</literal>.</simpara>

/nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml:1389: element varlistentry: Relax-NG validity error : Did not expect element varlistentry there
  1385  </section>
  1386  </chapter>
  1387   <appendix xml:id="ch-options">
  1388    <title>Configuration Options</title>
  1389    <variablelist xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="home-manager-options" xml:base="nmd-result/home-manager-options.xml"><varlistentry><term xlink:href="#opt-_module.args" xml:id="opt-_module.args"><option>_module.args</option></term><listitem><simpara>Additional arguments passed to each module in addition to ones
  1390  like <literal>lib</literal>, <literal>config</literal>,
  1391  and <literal>pkgs</literal>, <literal>modulesPath</literal>.</simpara>

/nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml:1389: element varlistentry: Relax-NG validity error : Expecting element example, got varlistentry
  1385  </section>
  1386  </chapter>
  1387   <appendix xml:id="ch-options">
  1388    <title>Configuration Options</title>
  1389    <variablelist xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="home-manager-options" xml:base="nmd-result/home-manager-options.xml"><varlistentry><term xlink:href="#opt-_module.args" xml:id="opt-_module.args"><option>_module.args</option></term><listitem><simpara>Additional arguments passed to each module in addition to ones
  1390  like <literal>lib</literal>, <literal>config</literal>,
  1391  and <literal>pkgs</literal>, <literal>modulesPath</literal>.</simpara>

/nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml:1389: element varlistentry: Relax-NG validity error : Expecting element bridgehead, got varlistentry
  1385  </section>
  1386  </chapter>
  1387   <appendix xml:id="ch-options">
  1388    <title>Configuration Options</title>
  1389    <variablelist xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="home-manager-options" xml:base="nmd-result/home-manager-options.xml"><varlistentry><term xlink:href="#opt-_module.args" xml:id="opt-_module.args"><option>_module.args</option></term><listitem><simpara>Additional arguments passed to each module in addition to ones
  1390  like <literal>lib</literal>, <literal>config</literal>,
  1391  and <literal>pkgs</literal>, <literal>modulesPath</literal>.</simpara>

/nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml:1402: element listitem: Relax-NG validity error : Did not expect element listitem there
  1398  not bound to an attribute.</simpara>
  1399  <simpara>Some arguments are already passed by default, of which the
  1400  following <emphasis>cannot</emphasis> be changed with this option:</simpara>
  1401  <itemizedlist>
  1402  <listitem><para><simpara><varname>lib</varname>: The nixpkgs library.</simpara>
  1403  </para></listitem>
  1404  <listitem><para><simpara><varname>config</varname>: The results of all options after merging the values from all modules together.</simpara>

/nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml fails to validate
error: builder for '/nix/store/zvjbxmv90w44cdq501lc5jnbl2f8sw2w-manual-combined.drv' failed with exit code 3;
       last 10 log lines:
       > /nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml:1402: element listitem: Relax-NG validity error : Did not expect element listitem there
       >   1398        not bound to an attribute.</simpara>
       >   1399    <simpara>Some arguments are already passed by default, of which the
       >   1400     following <emphasis>cannot</emphasis> be changed with this option:</simpara>
       >   1401    <itemizedlist>
       >   1402  <listitem><para><simpara><varname>lib</varname>: The nixpkgs library.</simpara>
       >   1403 </para></listitem>
       >   1404      <listitem><para><simpara><varname>config</varname>: The results of all options after merging the values from all modules together.</simpara>
       >
       > /nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml fails to validate
       For full logs, run 'nix log /nix/store/zvjbxmv90w44cdq501lc5jnbl2f8sw2w-manual-combined.drv'.

error: 1 dependencies of derivation '/nix/store/5j6wkrkz23j5609ydgs613inphcg6y6b-man-pages.drv' failed to build
error: 1 dependencies of derivation '/nix/store/d2qzx8i8pgpm7q3hdp8kycpmq13hqhwa-home-manager-applications.drv' failed to build
error: 1 dependencies of derivation '/nix/store/v93lkfq398x4nd7gry4c1a28bah4kchq-home-manager-fonts.drv' failed to build
error: 1 dependencies of derivation '/nix/store/0lx1cvf22qjpcws74irx9yqcll0084hl-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2ba5a6qhvrin483j8v97bigczrwrrd0b-man-pages-fish-completions.drv' failed to build
error: 1 dependencies of derivation '/nix/store/87nfwaqcgl14if7fl53i2jyg5b6hwvlm-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/5j7ichyb6gf1a8b5shq90vic0l3ild59-activation-raziel.drv' failed to build
error: 1 dependencies of derivation '/nix/store/nawdrn3dfs0ajcww8aiqqpc5vw4plqyr-darwin-system-23.05pre439589.298add347c2+darwin4.0000000.drv' failed to build

Maintainer CC

Not sure ?

System information

- system: `"aarch64-darwin"`
 - host os: `Darwin 22.2.0, macOS 13.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.12.0`
 - channels(raziel): `"darwin, home-manager, unstable"`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
ncfavier commented 1 year ago

This looks like a duplicate of https://github.com/NixOS/nixpkgs/issues/196651 (it's hard to tell because DocBook errors are not that informative...)

What branch of home-manager are you following? Are you sure you're on the latest revision?

The following information would be useful:

dinkopehar commented 1 year ago

@ncfavier Thank you for quick response.

I will update this issue soon when I'm back in few hours with info you requested and try that solution in duplicate you mentioned.

I just updated nix channels so I assume I'm on latest revisions of Home manager(master), but will update to be sure.

dinkopehar commented 1 year ago

@ncfavier Thank you for your help. Adding the mentioned (manual.manpages.enable = false;) makes it work again 🚀

You asked about revisions, I'm not expert on Nix still but I guess:

In conclusion, I guess it is something related to the issue you mentioned so you can close this one because it resolved problems for me.

ncfavier commented 1 year ago

Okay, so maybe it is a different issue. Could you paste the contents of that /nix/store/9ff1wzw2fyfj7qmpss1q6sygix4x7m9h-manual-combined/manual-combined.xml file to https://gist.github.com/ ?

dinkopehar commented 1 year ago

Here is the content of file you request for further investigation - https://gist.github.com/dinko-pehar/15bccbb2f04dc05746f4ab6375d3e6e0

ncfavier commented 1 year ago

Thanks, that's helpful.

That file fails to validate against the DocBook stylesheet because it contains <simpara> tags inside <para> tags, which isn't allowed (of course, the error couldn't just say that, that would be too simple...).

These errors are only present in the description for _module.args:

_module.args docbook ```xml Additional arguments passed to each module in addition to ones like lib, config, and pkgs, modulesPath. This option is also available to all submodules. Submodules do not inherit args from their parent module, nor do they provide args to their parent module or sibling submodules. The sole exception to this is the argument name which is provided by parent modules to a submodule and contains the attribute name the submodule is bound to, or a unique generated name if it is not bound to an attribute. Some arguments are already passed by default, of which the following cannot be changed with this option: lib: The nixpkgs library. config: The results of all options after merging the values from all modules together. options: The options declared in all modules. specialArgs: The specialArgs argument passed to evalModules. All attributes of specialArgs Whereas option values can generally depend on other option values thanks to laziness, this does not apply to imports, which must be computed statically before anything else. For this reason, callers of the module system can provide specialArgs which are available during import resolution. For NixOS, specialArgs includes modulesPath, which allows you to import extra modules from the nixpkgs package tree without having to somehow make the module aware of the location of the nixpkgs or NixOS directories. { modulesPath, ... }: { imports = [ (modulesPath + "/profiles/minimal.nix") ]; } For NixOS, the default value for this option includes at least this argument: pkgs: The nixpkgs package set according to the option. Type: lazy attribute set of raw valueDeclared by: <home-manager/lib/modules.nix> ```

I'm guessing the fix would be to remove the <para> tags here.

It is weird that your manual is generating documentation for _module.args, though, because that option was made invisible in https://github.com/NixOS/nixpkgs/pull/208407, which is on unstable and 22.11. Could you try updating nixpkgs?

cc @pennae for good measure

ncfavier commented 1 year ago

I'm guessing the fix would be to remove the <para> tags here.

Nope, that's not it. Still struggling to find what the error is exactly...

pennae commented 1 year ago

it looks like the current HM markdown converter is just plain wrong. always wrapping paragraphs in simpara (https://gitlab.com/rycee/nmd/-/blob/master/lib/docbookify-options-json.py#L83) plus post-conversion unwrapping (https://gitlab.com/rycee/nmd/-/blob/master/lib/docbookify-options-json.py#L274) should produce incorrect results on all block containers, which notably includes admonitions. simpara should be replaced with para in all places and unwrapping removed, we'd think

pennae commented 1 year ago

nixos/nixpkgs#215924 had pretty much the same failure not too long, there it went away with an all-channels update

spinkyspider commented 1 year ago

So, I'm pretty sure I've got a different bug, but it is manifesting in the same/similar way as this issue. My rebuild switch starts failing at manual-combined.drv and goes on to complain about opt-targets.darwin.defaults."com.apple.Safari".blah blah blah.

But, I'm not running darwin. :-( I am, however, running on Apple hardware.(Macbook Pro 7,1)

So, I don't know, maybe same, maybe not. I'm not a coder. Can someone look over my commands and outputs and let me know if this is a new issue or not?

Thanks.

home-manager.failure-to-install.vim.txt

dinkopehar commented 1 year ago

I've just updated all channels and it's still happening. I have disabled it as suggested above by @ncfavier . It's not important to me. If there is any way I could help more with this, please write.

rycee commented 1 year ago

Yeah, the validation error shows up when running

 nix build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/298add347c2.tar.gz -f. docs.html

but it seems to work with the latest Nixpkgs unstable

nix build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz -f. docs.html
ncfavier commented 1 year ago

@spinkyspider that looks like an instance of https://github.com/NixOS/nixpkgs/issues/196651, i.e. caused by the changes in showOption in nixpkgs. The fixes for that have landed in both home-manager and nix-darwin a while ago, so I suggest you update everything.

ncfavier commented 1 year ago

@dinko-pehar are you sure you're correctly updating the nixpkgs channel that nix-darwin uses? Are you running nix-channel as root or as your own user?

dinkopehar commented 1 year ago

@ncfavier I've updated as root but now I have problems with chromium enabled on darwin. I'll get back to you once I resolve this.

dinkopehar commented 1 year ago

Finally, it's resolved. Many thanks to you for supporting me.

I usually ran nix-channel --update and I assumed it updates all channels because it pulled Neovim update from few weeks ago. I didn't do sudo nix-channel --update so this was the problem for me I think. There are too many moving parts while maintaining everything with nix that I need to learn to be able to understand errors better. I'll try in future to help home-manager and contribute if I can.

Thank you 👍

ncfavier commented 1 year ago

@fricklerhandwerk you asked about Nix UX pain points, I think this is a pretty common one: confusion about root vs. user channels. (Of course, the real problem is that the sane alternative to channels, flakes, are not stable yet...)

spinkyspider commented 1 year ago

@spinkyspider that looks like an instance of NixOS/nixpkgs#196651, i.e. caused by the changes in showOption in nixpkgs. The fixes for that have landed in both home-manager and nix-darwin a while ago, so I suggest you update everything.

@ncfavier Could you clarify, for a nixos newb, what you mean by "update everything"? In my attached file I thought it shows that I updated everything. Do you mean I need to update to the bleeding edge Master branch?

Also, I looked at 196651 and it seems to be darwin specific. Am I just wrong about that? Thanks.

ncfavier commented 1 year ago

You're tracking the release-21.11 branch of home-manager, which is outdated. Try release-22.11.

The linked issue affects both nix-darwin and home-manager, regardless of platform.

nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/segmentation-faults-when-building-with-flake-on-raspberry-pi-3b/27069/5

seh commented 1 year ago

Since I'm running into this same problem with a fresh installation of Nix on macOS, I tried running both nix-channel --update and sudo nix-channel --update. The former succeeds, but the latter warns:

warning: $HOME ('/Users/seh') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root') unpacking channels... warning: $HOME ('/Users/seh') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')

I can see that in my ~/.nix-defexpr directory, there are separate symbolic links: channels and _channelsroot. I'm not sure whether that's pertinent here, though.

I confirmed that my flake.lock file includes the Git commit hashes for the head commits in both the home-manager and nix-darwin repositories. What else might I need to update to get past this DocBook schema conformance problem?

ncfavier commented 1 year ago

Why are you using both flakes and channels?

seh commented 1 year ago

I’m new enough to Nix that my best answer is, “I don’t know.”

I ran into the problem described here, and have been reading the advice and solutions that worked for others who asked about it before me. That led me to try the nix-channel commands.

ncfavier commented 1 year ago

If you're using flakes, as documented here, then channels should have no incidence at all.

How are you specifying your flake inputs, and what command are you running to get what error?

ncfavier commented 1 year ago

Also reported in https://github.com/nix-community/home-manager/issues/4142, this looks like it could be a new instance of this problem. Let's track the new issue there.

seh commented 1 year ago

How are you specifying your flake inputs, and what command are you running to get what error?

Just to answer this question, I'm trying to adapt @sebastiant's dotfiles repository, first just targeting one machine running macOS. I'm rewriting as I go, not installing all the programs yet; I'm just trying to get the skeleton working.

sebastiant commented 1 year ago

Indeed, channels are not relevant if using flakes. To not hijack the thread: feel free to reach out to me separately if you want assistance with nix or flakes in general.

The corresponding action to update your channel would be nix flake update https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake-update.html which will update all your flake inputs in the flake.lock file. Ill try to reproduce this on my mac from that repository tomorrow!

seh commented 1 year ago

feel free to reach out to me separately if you want assistance with nix or flakes in general.

Where would you prefer to have these discussions that probably don't warrant issues to be filed here? As an example, I now find that the jsonnet package (still using the C++ rather than the Go port) won't build on macOS, due to ld not being able to find symbols for the "x86_64" architecture.