Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/systemd: Handle template overrides
Adding template overrides allows for custom behavior for specific instances of a template. Previously, it was not possible to provide bind mounts for systemd-nspawn. This change allows it.
- Loading branch information
1 parent
102eb68
commit e3b90b6
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import ./make-test-python.nix { | ||
name = "systemd-template-override"; | ||
|
||
machine = { pkgs, lib, ... }: let | ||
touchTmp = pkgs.writeTextFile { | ||
name = "touch-tmp@.service"; | ||
text = '' | ||
[Service] | ||
Type=oneshot | ||
ExecStart=${pkgs.coreutils}/bin/touch /tmp/%I | ||
''; | ||
destination = "/etc/systemd/system/touch-tmp@.service"; | ||
}; | ||
in { | ||
systemd.packages = [ touchTmp ]; | ||
|
||
systemd.services."touch-tmp@forbidden" = { | ||
serviceConfig.ExecStart = [ "" '' | ||
${pkgs.coreutils}/bin/true | ||
'']; | ||
}; | ||
|
||
systemd.services."touch-tmp@intercept" = { | ||
serviceConfig.ExecStart = [ "" '' | ||
${pkgs.coreutils}/bin/touch /tmp/renamed | ||
'']; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
machine.wait_for_unit("default.target") | ||
machine.succeed("systemctl start touch-tmp@normal") | ||
machine.succeed("systemctl start touch-tmp@forbbidden") | ||
machine.succeed("systemctl start touch-tmp@intercept") | ||
machine.succeed("[ -e /tmp/normal ]") | ||
machine.succeed("[ ! -e /tmp/forbidden ]") | ||
machine.succeed("[ -e /tmp/renamed ]") | ||
''; | ||
} |
e3b90b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit broke a test and is now blocking the nixos-unstable channel (which needs fixing within a couple days). EDIT: nixos-unstable-small channel also contains the same test and is blocked now.