Commit Graph

10 Commits

Author SHA1 Message Date
Maximilian Bosch
b1a881edb9 nixos/user-activation-scripts: refactor assert
By using unittest's assertEqual you actually see how often the
activation script was being run, i.e. the expected value.

(cherry picked from commit 864a84d3e9)
2026-05-23 12:50:40 +02:00
r-vdp
663a59e0b6 nixos/activation: run user nixos-activation.service exactly once per switch
stc-ng starts every active target (including default.target) and then
explicitly restarts nixos-activation.service. As a Type=oneshot without
RemainAfterExit the unit is inactive after login, so the default.target
start job re-runs it via Wants=, and the explicit restart runs it again
(or, depending on ordering, SIGTERMs the currently running script and re-runs it).

Set RemainAfterExit=yes so target starts are a no-op for an already-run
activation, and restartIfChanged=false so the unit-diff pass leaves it
alone when the script changes. The explicit restart in stc-ng remains
the single trigger per switch. Print that restart so it is visible in
the switch output, and drop it from the "NOT restarting" list.

Extend the user-activation-scripts test to assert the activation is
only run once, and never killed.
2026-05-23 12:50:40 +02:00
Sizhe Zhao
f34483be5e nixosTests: handleTest -> runTest, batch 1
Reference: https://github.com/NixOS/nixpkgs/issues/386873
2025-05-26 20:40:17 +08:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
K900
b683d4dbbd nixos/tests/user-activation-scripts: enable switch-to-configuration 2024-09-08 17:09:02 +03:00
Jared Baur
e39c9f13bc nixos/systemd-user: call systemd-tmpfiles during activation
Just like with system-wide tmpfiles, call `systemd-tmpfiles --create
--remove` for users during activation. This fixes an issue where new
entries in a user's tmpfiles are not reflected after activation, only at
boot when the user service systemd-tmpfiles-setup.service runs or only
after running systemd-tmpfiles manually.
2023-08-29 10:46:44 -07:00
Bobby Rong
906b0b2e87 nixos/tests: fix all tests that uses wait_until_tty_matches 2022-06-04 12:22:03 +08:00
Robert Hensing
aa0f27abb0 treewide: machine -> nodes.machine 2022-03-28 14:11:58 +02:00
Chuck
df25ca8520 nixos/activation-script: Run userActivationScripts at login
Fixes https://github.com/NixOS/nixpkgs/issues/113240
2021-02-16 10:10:45 -08:00
Chuck
f6ddd253e0 nixos/activation-script: Add a test 2021-02-16 10:10:05 -08:00