7 ms·
NixOS comes with systemd, so I've been using it as a first-class part of managing stuff. It's great, especially coming from macOS' launchd. Which makes it nice
by hombre_fatal 5mo ago
NixOS comes with systemd, so I've been using it as a first-class part of managing stuff. It's great, especially coming from macOS' launchd.
Which makes it nice to distribute a tool for NixOS so that it can lean into systemd instead of as some bolted-on afterthought.
Makes me wonder what you'd do if you were distributing a lifecycle-heavy tool for Linux users in general since systemd isn't ubiquitous.
I use a systemd timer to run a monthly scrub for my btrfs pool. Kinda cool how you can do increasingly useful things like skip the next scheduled event if the user initiates a scrub, do or don't accumulate tasks if you have a monthly task but the machine was offline for 6 months -- or fold them into a single task, etc.
- drunner 5mo agoHave you been defining them directly in your flake.nix file? I too am on nixos but I keep all my configurations in their native format and symlink them with nix, that way I can take and reuse that config on a non nixos system easily. The problem I have found is that nixos doesn't seem to pickup and run systemd timers and services placed into the ~/.config/systems/user folder and additionally things like WantedBy=default.target have no effect. So after I restart all my services manually on reboot I agree, systems timers are cool.
- Cyph0n 5mo agoI define all units in Nix because: a) It is way nicer and you get decent validation at build time b) A LLM can port units over if the need arises; it’s a very light abstraction around systemd syntax c) I personally don’t see how I would ever move to another distro :)
- zaik 5mo agob) Or you could take the compiled units from /etc/systemd and copy them wherever
- Cyph0n 5mo ago+1, NixOS makes working with systemd a breeze. Defining units in Nix beats wrangling INI files. systemd.services.sync-recyclarr = { serviceConfig.Type = "oneshot"; path = [ pkgs.podman ]; script = '' podman exec -it recyclarr recyclarr sync radarr podman exec -it recyclarr recyclarr sync sonarr ''; }; systemd.timers.sync-recyclarr = { timerConfig = { OnCalendar = "daily"; Persistent = true; Unit = "sync-recyclarr.service"; }; partOf = [ "sync-recyclarr.service" ]; requires = [ "podman-recyclarr.service" ]; wantedBy = [ "timers.target" ]; };
- Eduard 5mo agois this irony?
- Cyph0n 5mo agoNo. Is that not readable to you lol? I think anyone with even a passing familiarity with systemd would understand what that chunk of Nix is doing. Compare it to the alternative of using plain systemd (including command(s) required to enable units). Also, consider what build-time validation you get prior to starting the unit/timer. Hint: zero.
- okanat 5mo agoIt's significantly uglier and it also skips the helpful headers / sections in the systemd INI files. `[Unit]` and `[Service]` and `[Timer]` represent different layers of execution. Many Nix people got used to the horrible syntax of Nix, I guess? I still find Bitbake significantly more palatable than Nix. I do appreciate build-time checking but I think this can be solved at systemd side as a separate tool just as effectively.
- Cyph0n 5mo agoUgliness is subjective :) But my question was around readability: were you able to understand what the snippet I shared is doing? Re: build-time checks - but systemd hasn’t done it, and I am also unsure where exactly this verification would even take place given systemd’s configuration model. Unless you’re talking about some kind of language server or IDE integration.