Merge pull request #193502 from phaer/systemd-portabled

Support systemd-portabled
This commit is contained in:
Florian Klink 2022-10-04 21:39:39 +02:00 committed by GitHub
commit 72911a27bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 2 deletions

View file

@ -151,6 +151,9 @@ let
] ++ optionals cfg.package.withHostnamed [
"dbus-org.freedesktop.hostname1.service"
"systemd-hostnamed.service"
] ++ optionals cfg.package.withPortabled [
"dbus-org.freedesktop.portable1.service"
"systemd-portabled.service"
] ++ [
"systemd-exit.service"
"systemd-update-done.service"

View file

@ -82,6 +82,8 @@ in
"dbus-org.freedesktop.import1.service"
] ++ optionals config.systemd.package.withMachined [
"dbus-org.freedesktop.machine1.service"
] ++ optionals config.systemd.package.withPortabled [
"dbus-org.freedesktop.portable1.service"
] ++ [
"dbus-org.freedesktop.login1.service"
"user@.service"

View file

@ -79,6 +79,7 @@ in
ln -s "${systemd}/example/tmpfiles.d/home.conf"
ln -s "${systemd}/example/tmpfiles.d/journal-nocow.conf"
ln -s "${systemd}/example/tmpfiles.d/portables.conf"
ln -s "${systemd}/example/tmpfiles.d/static-nodes-permissions.conf"
ln -s "${systemd}/example/tmpfiles.d/systemd.conf"
ln -s "${systemd}/example/tmpfiles.d/systemd-nologin.conf"

View file

@ -610,6 +610,7 @@ in {
systemd-no-tainted = handleTest ./systemd-no-tainted.nix {};
systemd-nspawn = handleTest ./systemd-nspawn.nix {};
systemd-oomd = handleTest ./systemd-oomd.nix {};
systemd-portabled = handleTest ./systemd-portabled.nix {};
systemd-shutdown = handleTest ./systemd-shutdown.nix {};
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
systemd-misc = handleTest ./systemd-misc.nix {};

View file

@ -0,0 +1,51 @@
import ./make-test-python.nix ({pkgs, lib, ...}: let
demo-program = pkgs.writeShellScriptBin "demo" ''
while ${pkgs.coreutils}/bin/sleep 3; do
echo Hello World > /dev/null
done
'';
demo-service = pkgs.writeText "demo.service" ''
[Unit]
Description=demo service
Requires=demo.socket
After=demo.socket
[Service]
Type=simple
ExecStart=${demo-program}/bin/demo
Restart=always
[Install]
WantedBy=multi-user.target
Also=demo.socket
'';
demo-socket = pkgs.writeText "demo.socket" ''
[Unit]
Description=demo socket
[Socket]
ListenStream=/run/demo.sock
SocketMode=0666
[Install]
WantedBy=sockets.target
'';
demo-portable = pkgs.portableService {
pname = "demo";
version = "1.0";
description = ''A demo "Portable Service" for a shell program built with nix'';
units = [ demo-service demo-socket ];
};
in {
name = "systemd-portabled";
nodes.machine = {};
testScript = ''
machine.succeed("portablectl")
machine.wait_for_unit("systemd-portabled.service")
machine.succeed("portablectl attach --now --runtime ${demo-portable}/demo_1.0.raw")
machine.wait_for_unit("demo.service")
machine.succeed("portablectl detach --now --runtime demo_1.0")
machine.fail("systemctl status demo.service")
'';
})

View file

@ -92,7 +92,7 @@
, withOomd ? true
, withPCRE2 ? true
, withPolkit ? true
, withPortabled ? false
, withPortabled ? true
, withRemote ? !stdenv.hostPlatform.isMusl
, withResolved ? true
, withShellCompletions ? true
@ -679,7 +679,7 @@ stdenv.mkDerivation {
# runtime; otherwise we can't and we need to reboot.
interfaceVersion = 2;
inherit withCryptsetup withHostnamed withImportd withLocaled withMachined withTimedated withUtmp util-linux kmod kbd;
inherit withCryptsetup withHostnamed withImportd withLocaled withMachined withPortabled withTimedated withUtmp util-linux kmod kbd;
tests = {
inherit (nixosTests) switchTest;

View file

@ -25305,6 +25305,7 @@ with pkgs;
withOomd = false;
withPCRE2 = false;
withPolkit = false;
withPortabled = false;
withRemote = false;
withResolved = false;
withShellCompletions = false;