-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NixOS's systemd abstraction doesn't work with systemd template units #135557
Comments
Further, I added another service like: {
systemd.services."several-foos" = {
requires = [ "foo@fizz" "foo@buzz" ];
wantedBy = [ "default.target" ];
script = ''
'';
} and |
I've been successfully generating a target. Re-tested now on 21.05: {
systemd.targets.kresd = { # configure units started by default
wantedBy = [ "multi-user.target" ];
wants = [ "kres-cache-gc.service" ]
++ map (i: "kresd@${toString i}.service") (range 1 cfg.instances);
};
} |
Is the |
Provided by package and modified by service. |
I think the issue is unique to units which are created totally by the module system. |
As a workaround you should be able to define a pseudo-package that defines the service (i.e. creates the unit file "manually"). |
Duplicate of #80933? |
using instances of systemd services create by the module system in this does feel like it's behaving correctly: referencing templated units with parameters elsewhere invokes them as expected, and defining them through the module system defines them as though they hadn't existed before. maybe we should have a |
I think we should first model Exec* correctly before we revise are replace |
PR #186314 is now merged into master, which fixes this issue. A working example:
|
I don't think that example works anymore and we might be looking at a regression here. As in if I copy&paste this the $ cat /etc/systemd/system/[email protected]/overrides.conf
[Unit]
[Service]
Environment="LOCALE_ARCHIVE=/nix/store/9dij3pl4dkdxmxhasjw1pa9hzqv4rjlp-glibc-locales-2.39-52/lib/locale/locale-archive"
Environment="PATH=/nix/store/ysqx2xfzygv2rxl7nxnw48276z5ckppn-coreutils-9.5/bin:/nix/store/36rvynxwln7iz0qq3k1v3r1mna8bma8s-fi"
Environment="TZDIR=/nix/store/jyh52p2cxrjn8r4ywdv2am5pjkj1xcqa-tzdata-2024a/share/zoneinfo" # build with: nix-build <this file>
# then run: result/bin/run-nixos-vm
let
configuration =
{ pkgs, lib, config, ... }:
{
systemd.services."foo@" = {
scriptArgs = "%i";
script = ''
echo "$1"
'';
};
systemd.services."foo@example" = {
overrideStrategy = "asDropin";
};
services.getty.autologinUser = "root";
system.stateVersion = config.system.nixos.release;
virtualisation.vmVariant = {
virtualisation = {
qemu.options = [ "-vga virtio" ];
diskImage = null; # "./nixos.qcow2";
mountHostNixStore = true;
writableStoreUseTmpfs = false;
};
};
boot.loader.grub.device = "nodev";
fileSystems."/" = { };
}
;
commit = "a046c1202e11b62cbede5385ba64908feb7bfac4";
source = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${commit}.tar.gz";
};
in
(import "${source}/nixos/lib/eval-config.nix" {
system = "x86_64-linux";
modules = [ configuration ];
}).config.virtualisation.vmVariant.system.build.vm |
The override.conf should not have an exec setting, the the template service defines exec. Also the status dead looks as expected. |
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:
Expected behavior
Starting
foo@example
should run thefoo@example
template service.Actual behavior
Starting a template unit which is not defined by NixOS works fine:
However, starting the
foo@example
service, defined by NixOS fails:Notify maintainers
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result."x86_64-linux"
Linux 5.10.52, NixOS, 21.11.20210810.6f6ade6 (Porcupine)
yes
yes
nix-env (Nix) 2.4pre20210813_d581129
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information:
The text was updated successfully, but these errors were encountered: