Skip to content

Fix activation under Nix 2.3 and stop run function from discarding error messages#5067

Merged
rycee merged 2 commits intonix-community:masterfrom
deviant:fix-2.3-activation-failure
Mar 8, 2024
Merged

Fix activation under Nix 2.3 and stop run function from discarding error messages#5067
rycee merged 2 commits intonix-community:masterfrom
deviant:fix-2.3-activation-failure

Conversation

@deviant
Copy link
Copy Markdown
Contributor

@deviant deviant commented Feb 29, 2024

Description

This pull request contains two changes:

treewide: stop run from discarding error messages

Adds a --quiet flag to run, which functions similarly to (but is mutually exclusive with) its existing --silence flag. When applied, this redirects only standard output (unlike --silence, which also redirects standard error) to /dev/null, allowing errors and other diagnostics to be seen. This commit also replaces various usages of --silence with --quiet where the latter seems more appropriate.

Before this change, gratuitous suppression of diagnostic output resulted in me running into the following (rather confusing) failure message:

Feb 25 00:51:03 dysnomia systemd[1]: Starting Home Manager environment for v...
Feb 25 00:51:03 dysnomia hm-activate-v[2558844]: Starting Home Manager activation
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Activating checkFilesChanged
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Activating checkLinkTargets
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Activating writeBoundary
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Activating installPackages
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Activating linkGeneration
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Cleaning up orphan links from /home/v
Feb 25 00:51:04 dysnomia hm-activate-v[2558844]: Creating profile generation 24
Feb 25 00:51:04 dysnomia systemd[1]: home-manager-v.service: Main process exited, code=exited, status=1/FAILURE
Feb 25 00:51:04 dysnomia systemd[1]: home-manager-v.service: Failed with result 'exit-code'.
Feb 25 00:51:04 dysnomia systemd[1]: Failed to start Home Manager environment for v.

With --silence substituted for --quiet, the output instead looks like the following (with the cause of the failure being much more apparent):

Feb 28 23:57:16 dysnomia systemd[1]: Starting Home Manager environment for v...
Feb 28 23:57:16 dysnomia hm-activate-v[3846052]: Starting Home Manager activation
Feb 28 23:57:16 dysnomia hm-activate-v[3846052]: Activating checkFilesChanged
Feb 28 23:57:16 dysnomia hm-activate-v[3846052]: Activating checkLinkTargets
Feb 28 23:57:17 dysnomia hm-activate-v[3846052]: Activating writeBoundary
Feb 28 23:57:17 dysnomia hm-activate-v[3846052]: Activating installPackages
Feb 28 23:57:17 dysnomia hm-activate-v[3846052]: Activating linkGeneration
Feb 28 23:57:17 dysnomia hm-activate-v[3846052]: Cleaning up orphan links from /home/v
Feb 28 23:57:17 dysnomia hm-activate-v[3846052]: Creating profile generation 37
Feb 28 23:57:17 dysnomia hm-activate-v[3846159]: error: path '/home/v/.local/state/home-manager/gcroots/current-home' is not a valid garbage collector root; it's not in the directory '/nix/var/nix/gcroots'
Feb 28 23:57:17 dysnomia systemd[1]: home-manager-v.service: Main process exited, code=exited, status=1/FAILURE
Feb 28 23:57:17 dysnomia systemd[1]: home-manager-v.service: Failed with result 'exit-code'.
Feb 28 23:57:17 dysnomia systemd[1]: Failed to start Home Manager environment for v.

files: fix activation under Nix 2.3

Adds the --indirect flag to a failing nix-store --add-root invocation in the activation script. This flag is required in Nix 2.3 if creating a garbage collector root outside of /nix/var/nix/gcroots. In subsequent versions of Nix, all garbage collector roots created by --add-root are indirect, and the flag is a no-op.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

deviant added 2 commits March 8, 2024 23:54
In most cases where this function is used, suppressing only the standard
output is more appropriate. Culling diagnostic output hides error
messages and makes debugging more difficult and confusing.

`$DRY_RUN_NULL`, which the `--silence` flag replaced, was used both for
suppressing standard output on its own, and for doing so along with
diagnostic output; however, when the `run` function was added this
distinction was lost, and both outputs would be discarded.

This reintroduces the needed functionality, and changes usages of
`--silence` to `--quiet` where previously only standard output was
suppressed, or where this should have probably been the case anyway.

Change-Id: Ifb1b52a1d1eea0117261c782d686ad7c71b43162
In Nix 2.3, all GC roots must be stored under `/nix/var/nix/gcroots`,
unless `--indirect` is specified. In Nix 2.4 and above, this flag is
ignored, because all GC roots created by `--add-root` are indirect.

Change-Id: I3eb3d7bc774af2ff336a2cdf312d30a99cdcb928
@rycee rycee force-pushed the fix-2.3-activation-failure branch from 376865a to 1743197 Compare March 8, 2024 22:55
@rycee rycee merged commit 1743197 into nix-community:master Mar 8, 2024
@rycee
Copy link
Copy Markdown
Member

rycee commented Mar 8, 2024

Thanks, that's great! Merged to master now 🙂

@deviant deviant deleted the fix-2.3-activation-failure branch March 8, 2024 23:14
tvlbot pushed a commit to tvlfyi/tvix that referenced this pull request Mar 11, 2025
* Bump Emacs 29 to 30 to address CVEs in prior versions:
  NixOS/nixpkgs#386174

* //3p/overlays/tvl:

  - Drop upstreamed fix for buildkite-agent
  - Drop tpm2-pkcs11 patch for an issue that has been
    addressed in 1.9.1.
  - Drop Nix 2.3 patch for home-manager. An alternative
    to it has been upstreamed in
    <nix-community/home-manager#5067>.

* //users/flokli/presentations: disable derivations that have
  been failing since the latest chromium upgrade (presumably).
  reveal-md … --print fails to export a PDF. Enabling debug
  output reveals that a timeout in pupeteer is hit.

Change-Id: Id83eb5e5fe2db77e648817c5c737b2f95b43deeb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13217
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
tvlbot pushed a commit to tvlfyi/kit that referenced this pull request Mar 11, 2025
* Bump Emacs 29 to 30 to address CVEs in prior versions:
  NixOS/nixpkgs#386174

* //3p/overlays/tvl:

  - Drop upstreamed fix for buildkite-agent
  - Drop tpm2-pkcs11 patch for an issue that has been
    addressed in 1.9.1.
  - Drop Nix 2.3 patch for home-manager. An alternative
    to it has been upstreamed in
    <nix-community/home-manager#5067>.

* //users/flokli/presentations: disable derivations that have
  been failing since the latest chromium upgrade (presumably).
  reveal-md … --print fails to export a PDF. Enabling debug
  output reveals that a timeout in pupeteer is hit.

Change-Id: Id83eb5e5fe2db77e648817c5c737b2f95b43deeb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13217
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
flokli pushed a commit to flokli/slides that referenced this pull request Mar 23, 2025
* Bump Emacs 29 to 30 to address CVEs in prior versions:
  NixOS/nixpkgs#386174

* //3p/overlays/tvl:

  - Drop upstreamed fix for buildkite-agent
  - Drop tpm2-pkcs11 patch for an issue that has been
    addressed in 1.9.1.
  - Drop Nix 2.3 patch for home-manager. An alternative
    to it has been upstreamed in
    <nix-community/home-manager#5067>.

* //users/flokli/presentations: disable derivations that have
  been failing since the latest chromium upgrade (presumably).
  reveal-md … --print fails to export a PDF. Enabling debug
  output reveals that a timeout in pupeteer is hit.

Change-Id: Id83eb5e5fe2db77e648817c5c737b2f95b43deeb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13217
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
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

Successfully merging this pull request may close these issues.

2 participants