Loading nixos/doc/manual/administration/service-mgmt.chapter.md +22 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,28 @@ Hence [garbage collection](#sec-nix-gc) will remove that file and you will wind up with a broken symlink in your systemd configuration, which in turn will not make the service / timer start on login. ## Template units {#sect-nixos-systemd-template-units} ### Defining custom services {#sect-nixos-systemd-custom-services} You can define services by adding them to `systemd.services`: ```nix systemd.services.myservice = { after = [ "network-online.target" ]; requires = [ "network-online.target" ]; before = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { ExecStart = "..."; }; }; ``` If you want to specify a multi-line script for `ExecStart`, you may want to use `pkgs.writeShellScript`. ### Template units {#sect-nixos-systemd-template-units} systemd supports templated units where a base unit can be started multiple times with a different parameter. The syntax to accomplish this is Loading nixos/doc/manual/redirects.json +3 −0 Original line number Diff line number Diff line Loading @@ -1556,6 +1556,9 @@ "sect-nixos-systemd-nixos": [ "index.html#sect-nixos-systemd-nixos" ], "sect-nixos-systemd-custom-services": [ "index.html#sect-nixos-systemd-custom-services" ], "sect-nixos-systemd-template-units": [ "index.html#sect-nixos-systemd-template-units" ], Loading Loading
nixos/doc/manual/administration/service-mgmt.chapter.md +22 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,28 @@ Hence [garbage collection](#sec-nix-gc) will remove that file and you will wind up with a broken symlink in your systemd configuration, which in turn will not make the service / timer start on login. ## Template units {#sect-nixos-systemd-template-units} ### Defining custom services {#sect-nixos-systemd-custom-services} You can define services by adding them to `systemd.services`: ```nix systemd.services.myservice = { after = [ "network-online.target" ]; requires = [ "network-online.target" ]; before = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { ExecStart = "..."; }; }; ``` If you want to specify a multi-line script for `ExecStart`, you may want to use `pkgs.writeShellScript`. ### Template units {#sect-nixos-systemd-template-units} systemd supports templated units where a base unit can be started multiple times with a different parameter. The syntax to accomplish this is Loading
nixos/doc/manual/redirects.json +3 −0 Original line number Diff line number Diff line Loading @@ -1556,6 +1556,9 @@ "sect-nixos-systemd-nixos": [ "index.html#sect-nixos-systemd-nixos" ], "sect-nixos-systemd-custom-services": [ "index.html#sect-nixos-systemd-custom-services" ], "sect-nixos-systemd-template-units": [ "index.html#sect-nixos-systemd-template-units" ], Loading