-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
No way to instantiate systemd template units #108054
Labels
0.kind: bug
Something is broken
Comments
10 tasks
Possible duplicate of #80933 |
yes, dup of #80933. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Here is a workaround for those that are interested: { config, lib, pkgs, ... }: {
systemd.packages = [
(pkgs.runCommandNoCC "machines" {
preferLocalBuild = true;
allowSubstitutes = false;
} ''
mkdir -p $out/etc/systemd/system/
ln -s /etc/systemd/system/[email protected] $out/etc/systemd/system/[email protected]
'')
];
systemd.services."systemd-nspawn@archlinux".wantedBy = [ "machines.target" ];
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Systemd has the notion of template units, e.g.
[email protected]
is such a unit. These template units contain common configuration that is suppose to be shared among all instances of this template. For example on a typical Linux distribution it would be possible to instantiate the aforementioned unit for a particular machineSomething similar is currently not possible on NixOS. Trying to use
will create an entirely new unit from scratch, completely ignoring the existence of the template
[email protected]
. Even worse, because/etc/systemd/system
links into the read-only Nix store, it's not even possible to instantiate the template in a stateful manner:To Reproduce
Steps to reproduce the behavior:
systemd.services."systemd-nspawn@archlinux".enable = true;
to/etc/nixos/configuration.nix
.systemctl cat [email protected]
andsystemctl cat [email protected]
and see that they have nothing to do with each other.Expected behavior
Template units are a powerful concept of systemd and it would be beneficial if NixOS users could take advantage of it.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Notify maintainers
The
systemd
module doesn't have a maintainer field, so I'm pinging thesystemd
package maintainers: @andir @eelco @flokliMetadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result."x86_64-linux"
Linux 5.9.16, NixOS, 20.09.2405.e065200fc90 (Nightingale)
yes
yes
nix-env (Nix) 2.4pre20201201_5a6ddb3
/etc/channels/nixos
Maintainer information:
The text was updated successfully, but these errors were encountered: