NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.37k stars 13.59k forks source link

systemctl mask --runtime has no effect #252591

Open farnoy opened 1 year ago

farnoy commented 1 year ago

Describe the bug

Using systemctl mask --runtime $unit has no effect.

Steps To Reproduce

Steps to reproduce the behavior:

  1. systemctl mask --runtime display-manager.service
  2. The command is successful and places a symlink in /run/systemd/system/display-manager.service
  3. It has no effect on systemd's outlook on that service:
    # systemctl status display-manager
    ● display-manager.service - X11 Server
     Loaded: loaded (/etc/systemd/system/display-manager.service; enabled-runtime; preset: enabled)
     Active: active (running) since Thu 2023-08-31 16:57:22 CEST; 40min ago

Expected behavior

I expected to see

# systemctl status display-manager
● display-manager.service
     Loaded: masked (Reason: Unit display-manager.service is masked.)
     Active: active (running) since Thu 2023-08-31 16:57:22 CEST; 43min ago

Which is what happens after the transient workaround below.

Screenshots

Additional context

There is a workaround in this post: https://discourse.nixos.org/t/temporarily-disabling-a-systemd-service/26225/13

It does work locally for me if I do

# ln -s /dev/null /run/systemd/transient/display-manager.service
# systemctl daemon-reload

Notify maintainers

@NixOS/systemd

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.4.12, NixOS, 23.05 (Stoat), 23.05.20230829.2ab91c8`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.5`
 - channels(root): `"home-manager, nixos"`
 - channels(kuba): `"home-manager, nixpkgs"`
 - nixpkgs: `not found`
ElvishJerricco commented 2 months ago

This is a quirk of the fact that nixos puts its systemd configuration in /etc rather than /usr/lib, because systemd prioritizes /etc over /run over /usr/lib.