NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.84k stars 13.22k forks source link

Many systemd units are not-found after fresh install #88597

Open datafoo opened 4 years ago

datafoo commented 4 years ago

Describe the bug Many systemd units are not-found after a fresh install.

To Reproduce

  1. Install NixOS from a recent ISO
  2. Run systemctl list-units --state not-found

Expected behavior A fresh and clean install should not have not-found units.

Additional context

In my case (no graphical user interface), here is what I see:

# systemctl list-units --state not-found
  UNIT                              LOAD      ACTIVE   SUB  DESCRIPTION                      
● proc-sys-fs-binfmt_misc.automount not-found inactive dead proc-sys-fs-binfmt_misc.automount
● proc-sys-fs-binfmt_misc.mount     not-found inactive dead proc-sys-fs-binfmt_misc.mount    
● tmp.mount                         not-found inactive dead tmp.mount                        
● auditd.service                    not-found inactive dead auditd.service                   
● display-manager.service           not-found inactive dead display-manager.service          
● dracut-mount.service              not-found inactive dead dracut-mount.service             
● nfs-kernel-server.service         not-found inactive dead nfs-kernel-server.service        
● nfs-server.service                not-found inactive dead nfs-server.service               
● plymouth-quit-wait.service        not-found inactive dead plymouth-quit-wait.service       
● plymouth-start.service            not-found inactive dead plymouth-start.service           
● rpc-statd-notify.service          not-found inactive dead rpc-statd-notify.service         
● smb.service                       not-found inactive dead smb.service                      
● syslog.service                    not-found inactive dead syslog.service                   
● systemd-hwdb-update.service       not-found inactive dead systemd-hwdb-update.service      
● systemd-quotacheck.service        not-found inactive dead systemd-quotacheck.service       
● systemd-sysusers.service          not-found inactive dead systemd-sysusers.service         
● cryptsetup.target                 not-found inactive dead cryptsetup.target                
● initrd-switch-root.target         not-found inactive dead initrd-switch-root.target        
● time-set.target                   not-found inactive dead time-set.target                  

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

19 loaded units listed.

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

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.42, NixOS, 20.03.1943.de493bd7492 (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.4`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
flokli commented 4 years ago

@datafoo most of these are probably caused by After= (or Wants=) referring to unit files not installed. Having After= referring to a non-existent unit file is probably fine, just a bit ugly.

Can you grep which unit files refer the mentioned unites, and add this info to the list?

That should make things a bit easier to dive into.

datafoo commented 4 years ago

I have update the list with the results from these commands:

systemctl list-dependencies --reverse tmp.mount
systemctl list-dependencies --reverse auditd.service
systemctl list-dependencies --reverse display-manager.service
systemctl list-dependencies --reverse dracut-mount.service
systemctl list-dependencies --reverse nfs-kernel-server.service
systemctl list-dependencies --reverse nfs-server.service
systemctl list-dependencies --reverse plymouth-quit-wait.service
systemctl list-dependencies --reverse plymouth-start.service
systemctl list-dependencies --reverse rpc-statd-notify.service
systemctl list-dependencies --reverse smb.service
systemctl list-dependencies --reverse syslog.service
systemctl list-dependencies --reverse systemd-hwdb-update.service
systemctl list-dependencies --reverse systemd-quotacheck.service
systemctl list-dependencies --reverse systemd-sysusers.service
systemctl list-dependencies --reverse cryptsetup.target
systemctl list-dependencies --reverse initrd-switch-root.target
systemctl list-dependencies --reverse time-set.target

systemctl list-dependencies --before tmp.mount
systemctl list-dependencies --before auditd.service
systemctl list-dependencies --before display-manager.service
systemctl list-dependencies --before dracut-mount.service
systemctl list-dependencies --before nfs-kernel-server.service
systemctl list-dependencies --before nfs-server.service
systemctl list-dependencies --before plymouth-quit-wait.service
systemctl list-dependencies --before plymouth-start.service
systemctl list-dependencies --before rpc-statd-notify.service
systemctl list-dependencies --before smb.service
systemctl list-dependencies --before syslog.service
systemctl list-dependencies --before systemd-hwdb-update.service
systemctl list-dependencies --before systemd-quotacheck.service
systemctl list-dependencies --before systemd-sysusers.service
systemctl list-dependencies --before cryptsetup.target
systemctl list-dependencies --before initrd-switch-root.target
systemctl list-dependencies --before time-set.target

systemctl list-dependencies --after tmp.mount
systemctl list-dependencies --after auditd.service
systemctl list-dependencies --after display-manager.service
systemctl list-dependencies --after dracut-mount.service
systemctl list-dependencies --after nfs-kernel-server.service
systemctl list-dependencies --after nfs-server.service
systemctl list-dependencies --after plymouth-quit-wait.service
systemctl list-dependencies --after plymouth-start.service
systemctl list-dependencies --after rpc-statd-notify.service
systemctl list-dependencies --after smb.service
systemctl list-dependencies --after syslog.service
systemctl list-dependencies --after systemd-hwdb-update.service
systemctl list-dependencies --after systemd-quotacheck.service
systemctl list-dependencies --after systemd-sysusers.service
systemctl list-dependencies --after cryptsetup.target
systemctl list-dependencies --after initrd-switch-root.target
systemctl list-dependencies --after time-set.target
flokli commented 4 years ago

As written in https://github.com/NixOS/nixpkgs/issues/90188, some of these missing units seem to be already caused by upstream units - you might want to check the systemd/systemd issue tracker regarding those, and whether these should be considered an error.

The tmp.mount one is a good example of such a thing.

These occurences might also be configuration-specific - we currently build systemd without cryptsetup (work ongoing in https://github.com/NixOS/nixpkgs/pull/66856), but systemd-ask-password-console.path and systemd-ask-password-wall.path unconditionally refer to cryptsetup.target. This should be rendered by meson, and made conditional on whether systemd is built with cryptsetup support or not.

Happy to fix these warnings where we cause them (as we did in https://github.com/NixOS/nixpkgs/pull/87742), but we shouldn't try to patch around systemd downstream if it's caused upstream.

datafoo commented 4 years ago

Happy to fix these warnings where we cause them (as we did in #87742), but we shouldn't try to patch around systemd downstream if it's caused upstream.

That makes sense.

So, from my understanding, only the followings are not from the native systemd:

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

flokli commented 3 years ago

@datafoo The whole zfs-* dependencies seem to be coming from the zfs package itself - I'd encourage opening bug reports there, or re-creating these units in nixos/modules/tasks/filesystems/zfs.nix, and having them conditionally on the corresponding services to be enabled.

I just opened https://github.com/NixOS/nixpkgs/pull/106787, which fixes the other occurence.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

JeffreyBenjaminBrown commented 1 year ago

(I first posted this same issue on the NixOS Discourse.)

I'm having a similar problem -- specifically, the error, "Unit window-manager.service not found", which is preventing me from using the graphical desktop environment (in my case, KDE).

I installed NixOS 22.05 on a new machine using the latest (as of Friday, 2022-11-04) Plasma .iso. Plasma didn't load in the installer, so I installed from the command line. When I boot, Plasma still doesn't load.

Apeing some instructions in the NixOS manual, I log into this bare-shell system and attempt to start KDE manually. I have the following interaction:

[jeff@gobbledygook]$ systemctl start display-manager
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authenticating as: jeff # I typed this in
Password:               # I typed this in, too, though you can't see it
==== AUTHENTICATION COMPLETE ====

[jeff@gobbledygook]$ systemctl start window-manager
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authenticating as: jeff # I typed this in
Password:               # I typed this in, too, though you can't see it
==== AUTHENTICATION COMPLETE ====
Failed to start window-manager.service: Unit window-manager.service not found.

My configuration on this system is extremely basic. (I always start new systems that way.) I haven't run any channel-related commands except sudo nix-channel --list, which reports that I'm on nixos-22.05.