Disable sage doc build

In my configuration.nix, I have sage installed with some custom python packages.

  nixpkgs.config.packageOverrides = rec {
    mysage = pkgs.sage.override {
      requireSageTests = false;
      withDoc = false; # NOT WORKING
      extraPythonPackages = ps: with ps; [ pycryptodomex lxml ];

I would like for it NOT to build the docs. As you can see, I tried to disable them, but they are rebuilt every time there is an update to one of the python packages.
Here is what i see with nixos-rebuild switch :

[1/292/304 built, 344 copied (9748.2/9749.6 MiB), 2286.0 MiB DL] building sagedoc-10.0 (buildPhase): [plotting ] <string>:53: UserWarning: The figure layout has changed to tight

Try to find out how your system is depending on sagedoc

nix path-info -r /run/current-system | grep sage
if it does not appear there then
nix path-info -r /run/current-system --derivation | grep sage
then once you have the path

nix why-depends /run/current-system "storepathhere" --all --precise
if the store path ends in .drv then add --derivation to the end

Thanks for the reply.

The store path is visible with the first command:

λ nix path-info -r /run/current-system | grep sage

This is the output of why-depends:

λ nix why-depends /run/current-system "/nix/store/ajn3scafiyz3kni8pjgcf1ra51ddgkdn-sagedoc-10.0" --all --precise
│   → /nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path
│       → /nix/store/ajn3scafiyz3kni8pjgcf1ra51ddgkdn-sagedoc-10.0
    → /nix/store/0fy000pzcasrq3mkz1v06ad3rrj31y7b-etc
    │   → /nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path
    │   → /nix/store/n1bjkv9y4a3radhxigcblyi2apklsib4-dbus-1
    │       → /nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path
    │   → /nix/store/5ix7lk770fd5rqila2hvqgs2qdazvkjp-system-units
    │   │   → /nix/store/xzjkncj5k654gifnxns3qlmqfsavq2j7-unit-polkit.service
    │   │       → /nix/store/c3a8m5layg7r8ak390dawkpjlvpf6fxh-X-Restart-Triggers
    │   │           → /nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path
    │       → /nix/store/mnw12d88886km0lisigfqgamca5j7naz-unit-dbus.service
    │           → /nix/store/iyxda6x1xvdmx1xqrkl5lkxwc9crng9v-X-Restart-Triggers
    │               → /nix/store/n1bjkv9y4a3radhxigcblyi2apklsib4-dbus-1
        → /nix/store/l1wqxvhbb8v2sw3kq6g2lvi2skmz02y8-user-units
            → /nix/store/0v1yjgcblqnr3dm5z3v47s9fd4glqwi0-unit-dbus.service
                → /nix/store/iyxda6x1xvdmx1xqrkl5lkxwc9crng9v-X-Restart-Triggers
├───sw -> /nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path
│   └───share/doc/sage -> /nix/store/ajn3scafiyz3kni8pjgcf1ra51ddgkdn-sagedoc-10.0/share/doc/sage
└───activate: …fsx38qi-setup-etc.pl /nix/store/0fy000pzcasrq3mkz1v06ad3rrj31y7b-etc/etc...if (( _localstatus > …
    etc -> /nix/store/0fy000pzcasrq3mkz1v06ad3rrj31y7b-etc/etc
    ├───etc/terminfo -> /nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path/share/terminfo
    ├───etc/dbus-1 -> /nix/store/n1bjkv9y4a3radhxigcblyi2apklsib4-dbus-1
    │   └───session.conf: …cludedir><servicedir>/nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path/share/dbus-1/servic…
    │       system.conf: …cludedir><servicedir>/nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path/share/dbus-1/system…
    ├───etc/systemd/system -> /nix/store/5ix7lk770fd5rqila2hvqgs2qdazvkjp-system-units
    │   ├───polkit.service.d/overrides.conf -> /nix/store/xzjkncj5k654gifnxns3qlmqfsavq2j7-unit-polkit.service/polkit.service
    │   │   └───polkit.service: …].X-Restart-Triggers=/nix/store/c3a8m5layg7r8ak390dawkpjlvpf6fxh-X-Restart-Triggers..[Service].E…
    │   │       └───/: …/nix/store/bnwh4mkyw4bka8wf657cm370b136j7ni-system-path…
    │   └───dbus.service.d/overrides.conf -> /nix/store/mnw12d88886km0lisigfqgamca5j7naz-unit-dbus.service/dbus.service
    │       └───dbus.service: …].X-Restart-Triggers=/nix/store/iyxda6x1xvdmx1xqrkl5lkxwc9crng9v-X-Restart-Triggers..[Service].E…
    │           └───/: …/nix/store/n1bjkv9y4a3radhxigcblyi2apklsib4-dbus-1…
    └───etc/systemd/user -> /nix/store/l1wqxvhbb8v2sw3kq6g2lvi2skmz02y8-user-units
        └───dbus.service.d/overrides.conf -> /nix/store/0v1yjgcblqnr3dm5z3v47s9fd4glqwi0-unit-dbus.service/dbus.service
            └───dbus.service: …].X-Restart-Triggers=/nix/store/iyxda6x1xvdmx1xqrkl5lkxwc9crng9v-X-Restart-Triggers..[Service].E…

I don’t really know what to look for now.

How do you actually install sage? AIUI, this says it’s in environment.systemPackage, rather than being installed through a user profile:

Granted, it should be a dependency of the sage wrapper, but I’m not sure that distinction will be visible: https://github.com/NixOS/nixpkgs/blob/4f77ea639305f1de0a14d9d41eef83313360638c/pkgs/applications/science/math/sage/sage.nix#L35

Anyway, looks like you’re just explicitly installing it with environment.systemPackages. So trying the obvious: Are you actually using your mysage? Not sure if this is a copy/paste error, but I’m fairly sure your packageOverrides is broken, since it’s supposed to have a function argument: Nixpkgs 23.05 manual | Nix & NixOS

Hence I wonder if your code ever actually executes. I’m also not sure if packageOverrides will actually apply correctly when used in configuration.nix, it’s only documented for user configuration, you should really be using the nixpkgs.overlays option in configuration.nix.

Even if packageOverrides actually does work when used like this, do you actually use the mysage attribute or are you under the rather common misconception that sage will have been changed to your mysage attribute?

Edit: Ah, yes, looks like support for use of that option is added here: https://github.com/NixOS/nixpkgs/blob/b89a0c676a402ad91bdfedc71b1ce924e07f5226/pkgs/top-level/stage.nix#L164

Still, I do not see how that can possibly work if your packageOverrides does not accept an argument. You should be getting an evaluation error.

Edit of the edit: I just tried it, wow, it works! Since when can you call a set with a set?

And I just tried this with a more normal overlay, and confirmed that it even happens with mysage as the defacto attribute used. Weirdness of config.packageOverrides aside then, the resulting sage wrapper does indeed not contain the sage docs:

#! /nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15/bin/bash -e
export SAGE_DOC_SRC_OVERRIDE='/nix/store/a2npb9nsmhxii0mg0pbxqhwn81wllj8b-sage-src-10.0/src/doc'
exec "/nix/store/j0xf93asykgz5j2i3dklbwm4aghai5fq-sage-with-env-10.0/bin/sage"  "$@" 

It must be pulled in by some other means, but the sage package is the only direct reference to sagedoc. withDoc is false by default in any case, so the overlay should be having no effect on whether docs are built whatsoever, and indeed it does not, docs are installed whether you use the with-docs package or the without-docs package. Something’s fishy, but I can’t spot the mistake.

They are in the passthru, but that should not be evaluated if it isn’t used?

Final edit for today:

tlater ~ $ nix why-depends /run/current-system nixpkgs#sage
tlater ~ $ nix why-depends /run/current-system nixpkgs#sage.doc
tlater ~ $ nix why-depends nixpkgs#sage nixpkgs#sage.doc
'flake:nixpkgs#sage' does not depend on 'flake:nixpkgs#sage.doc'

So adding the package to environment.systemPackages is enough to install the derivation the doc passthru points to, yet the sage derivation does not depend on the derivation in its doc passthru.

It couldn’t possibly be because environment.systemPackages somehow sees the doc attribute from the passthru as one of the outputs, could it?

1 Like
nix-repl> lib.getOutput "doc" sage
«derivation /nix/store/f9czqbgxp2k8r0fdkb0dy1iw7nvm0av9-sagedoc-10.0.drv»

This is why output or attribute should be behind not be included if the doc is disabled

1 Like

That’s… Awkward. I’d never considered that passthru attributes would be picked up by buildEnv.

I assume just renaming the doc passthru attribute is out of the question? The lib attr may also behave unexpectedly.

It’s not a bug, it’s a feature (multi-derivation packages), and in this case installing the docs when sageWithDocs is in systemPackages.