How to use toplevel-overrides for systemd

You can add your own packages to systemd.

{ config, lib, pkgs, ... }: {

  systemd.packages = [
    (pkgs.runCommandNoCC "toplevel-overrides.conf" {
      preferLocalBuild = true;
      allowSubstitutes = false;
    } ''
      mkdir -p $out/etc/systemd/system/service.d/
      echo "# Dummy" > $out/etc/systemd/system/service.d/toplevel-overrides.conf
    '')
  ];

}

If you want to use this with template units you have to change it a bit, see Declaring instances of a generic systemd service e.g. `my-service@foo`? - #5 by hmenke

2 Likes