Skip to content

NixOS's systemd abstraction doesn't work with systemd template units #135557

@grahamc

Description

@grahamc

Describe the bug

A clear and concise description of what the bug is.

Steps To Reproduce

Steps to reproduce the behavior:

Create a template unit, like:

{
  systemd.services."foo@" = {
    scriptArgs = "%i";
    script = ''
      echo "$1"
    '';
  };

  systemd.services."foo@example" = {};
}

Expected behavior

Starting foo@example should run the foo@example template service.

Actual behavior

Starting a template unit which is not defined by NixOS works fine:

# systemctl start foo@bar
# journalctl -fu foo@bar
-- Journal begins at Wed 2021-08-11 22:25:17 EDT. --
Aug 24 10:01:35 scruffy systemd[1]: Started [email protected].
Aug 24 10:01:35 scruffy foo_-start[3297689]: bar
Aug 24 10:01:35 scruffy systemd[1]: [email protected]: Succeeded.

However, starting the foo@example service, defined by NixOS fails:

# systemctl status foo@example
[email protected]
     Loaded: bad-setting (Reason: Unit [email protected] has a bad unit file setting.)
     Active: inactive (dead)

Aug 24 10:01:41 scruffy systemd[1]: [email protected]: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

  • system: "x86_64-linux"
  • host os: Linux 5.10.52, NixOS, 21.11.20210810.6f6ade6 (Porcupine)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20210813_d581129
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions