···118118Hence [garbage collection](#sec-nix-gc) will remove that file and you
119119will wind up with a broken symlink in your systemd configuration, which
120120in turn will not make the service / timer start on login.
121121+122122+## Template units {#sect-nixos-systemd-template-units}
123123+124124+systemd supports templated units where a base unit can be started multiple
125125+times with a different parameter. The syntax to accomplish this is
126126+`service-name@instance-name.service`. Units get the instance name passed to
127127+them (see `systemd.unit(5)`). NixOS has support for these kinds of units and
128128+for template-specific overrides. A service needs to be defined twice, once
129129+for the base unit and once for the instance. All instances must include
130130+`overrideStrategy = "asDropin"` for the change detection to work. This
131131+example illustrates this:
132132+```nix
133133+{
134134+ systemd.services = {
135135+ "base-unit@".serviceConfig = {
136136+ ExecStart = "...";
137137+ User = "...";
138138+ };
139139+ "base-unit@instance-a" = {
140140+ overrideStrategy = "asDropin"; # needed for templates to work
141141+ wantedBy = [ "multi-user.target" ]; # causes NixOS to manage the instance
142142+ };
143143+ "base-unit@instance-b" = {
144144+ overrideStrategy = "asDropin"; # needed for templates to work
145145+ wantedBy = [ "multi-user.target" ]; # causes NixOS to manage the instance
146146+ serviceConfig.User = "root"; # also override something for this specific instance
147147+ };
148148+ };
149149+}
150150+```