Hey guys. I’m a new NixOS user, who came from Fedora. I got a big issue with the previous OS on my hardware and my only option was to move somewhere else. Debian is old, Arch is not for me, Ubuntu is boring, Linux Mint is slow…
I heard about NixOS from Nick on TheLinuxExperiment, I think, a year ago, and was really excited about it at that time, but have never tried since then. (Really wanted to movebut everything was alright )
I dunno why so, but I got to know Nix from ver. 24.05, which has a broken graphical install. Right now, I’m writing from the test machine and understand that broken Calamares only made thins better. I’ve made my own configuration file as per wiki for my video editing purpose. The install went well, I’ve already tried creating several system profiles ( never got any bug or lock-up, which is very surprising!). I see myself daily-driving Nix
I’ve discovered only one missing feature while experimenting. Searching the Discourse or the web doesn’t help a lot. How can I list all installed services currently on the system? Something like systemd list-unit-files
in other SystemD distros (doesn’t work here: only shows system thifgs ).
AS per this topic, I can only list everything possible to configure.
Any ideas?
systemctl list-unit-files
and systemctl list-unit-files --user
seem to work fine, what’s the issue?
OK, so I have several apps with their services installed, as in Fedora:
setserial
samba
lm_sensors
smartmontools
anydesk
teamviewer
But when I run systemctl list-unit-files
and systemctl list-unit-files --user
, I see only samba
. Maybe it’s because how these packages are built for NixOS? Personally, It would be grear if I could start teamviewerd
using systemctl rather than using a symlink to the executable in my home folder.
How did you install them? What is the exact code you used?
What symlink is this?
environment.systemPackages = with pkgs; [
setserial
samba
lm_sensors
smartmontools
anydesk
teamviewer
];
[wynz@nixos-hp:~/Temp/Applications]$ ls -l
lrwxrwxrwx 1 wynz users 71 Jul 16 19:09 teamviewerd -> /nix/store/sxx3crbhkhli4cr0hfxyvv0p3wk4yvyf-system-path/bin/teamviewerd
Adding packages to environment.systemPackages
doesn’t create available services. If you look at the store path for, say, samba
, you won’t find any unit files there. They’re not part of the package in NixOS.
Systemd services are instead created with NixOS options such as services.samba.enable
. If that option is set to true, systemctl list-unit-files
should show a few Samba services; and likewise for your other programs.
For teamviewerd
, you want services.teamviewer.enable
, naturally.
(You can pop the hood on any of those options to see how the underlying systemd services are created, if you ever want to customize them or add your own. Long story short, they’re created by making attributes on systemd.services
.)
I got it! environment.systemPackages
just installs a package. services.<name>.enable
provides a SystemD unit file for it. And finally, systemd.services.<name>.wantedBy = ["multi-user.target"]
starts unit by default at boot time, right? Without this the unit won’t start at boot-up (that’s what I need)?
Yup, you got it!
Thanks mate!! Marking this as [SOLVED], everything works as expected :
[wynz@nixos-hp:~]$ systemctl status teamviewerd.service
● teamviewerd.service - TeamViewer remote control daemon
Loaded: loaded (/etc/systemd/system/teamviewerd.service; enabled; preset: enabled)
Active: active (running) since Tue 2024-07-16 19:55:46 EEST; 9s ago
Process: 9529 ExecStartPre=/nix/store/rdj1dig09x6f3vcxbfg8n7wvkk10hb1k-unit-script-teamviewerd-pre-start/>
Main PID: 9535 (.teamviewerd-wr)
IP: 0B in, 0B out
IO: 10.4M read, 28.0K written
Tasks: 17 (limit: 9244)
Memory: 13.2M (peak: 13.9M)
CPU: 82ms
CGroup: /system.slice/teamviewerd.service
└─9535 /nix/store/v0j41xggr4zkn1rx1vn0k4mjb05agp57-teamviewer-15.54.3/bin/teamviewerd -f
Jul 16 19:55:46 nixos-hp systemd[1]: Starting TeamViewer remote control daemon...
Jul 16 19:55:46 nixos-hp teamviewerd-pre-start[9534]: mkdir: created directory '/var/lib/teamviewer'
Jul 16 19:55:46 nixos-hp teamviewerd-pre-start[9534]: mkdir: created directory '/var/log/teamviewer'
Jul 16 19:55:46 nixos-hp systemd[1]: Started TeamViewer remote control daemon.
[wynz@nixos-hp:~]$ sudo systemctl stop teamviewerd.service
[wynz@nixos-hp:~]$
Oh, one last thing that I forgot to explicitly mention: services.<name>.enable
usually also adds the corresponding package to environment.systemPackages
, so you don’t need to do both.
In case there is no existing services.*
option in NixOS, but there is an upstream systemd service file, you can also put the package in systemd.packages
and customise it further.
Some modules will do this as well with the services.*.enable
option.