git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #87742 from flokli/systemd-binfmt

nixos/binfmt: move systemd-binfmt.service to binfmt module

commit528d35bec0cb976a06cc0e8487c6e5136400b16b authorFlorian Klink <flokli@flokli.de> dateMon 18 May 2020, 19:43 (6 years ago) parentb5caab6fd49155
4 files changed+30−6
nixos/modules/system/boot/binfmt.nix+5−4 nixos/modules/system/boot/systemd.nix−2 nixos/tests/all-tests.nix+1 nixos/tests/systemd-binfmt.nix+24
nixos/modules/system/boot/binfmt.nix+5−4
@@ -268,9 +268,10 @@ in {
268268 mkdir -p -m 0755 /run/binfmt
269269 ${lib.concatStringsSep "\n" (lib.mapAttrsToList activationSnippet config.boot.binfmt.registrations)}
270270 '';
271− systemd.additionalUpstreamSystemUnits = lib.mkIf (config.boot.binfmt.registrations != {})
272− [ "proc-sys-fs-binfmt_misc.automount"
273− "proc-sys-fs-binfmt_misc.mount"
274− ];
271+ systemd.additionalUpstreamSystemUnits = lib.mkIf (config.boot.binfmt.registrations != {}) [
272+ "proc-sys-fs-binfmt_misc.automount"
273+ "proc-sys-fs-binfmt_misc.mount"
274+ "systemd-binfmt.service"
275+ ];
275276 };
276277}
nixos/modules/system/boot/systemd.nix−2
@@ -164,7 +164,6 @@ let
164164 "systemd-timedated.service"
165165 "systemd-localed.service"
166166 "systemd-hostnamed.service"
167− "systemd-binfmt.service"
168167 "systemd-exit.service"
169168 "systemd-update-done.service"
170169 ] ++ optionals config.services.journald.enableHttpGateway [
@@ -1056,7 +1055,6 @@ in
10561055 systemd.targets.local-fs.unitConfig.X-StopOnReconfiguration = true;
10571056 systemd.targets.remote-fs.unitConfig.X-StopOnReconfiguration = true;
10581057 systemd.targets.network-online.wantedBy = [ "multi-user.target" ];
1059− systemd.services.systemd-binfmt.wants = [ "proc-sys-fs-binfmt_misc.mount" ];
10601058 systemd.services.systemd-importd.environment = proxy_env;
10611059
10621060 # Don't bother with certain units in containers.
nixos/tests/all-tests.nix+1
@@ -304,6 +304,7 @@ in
304304 syncthing-relay = handleTest ./syncthing-relay.nix {};
305305 systemd = handleTest ./systemd.nix {};
306306 systemd-analyze = handleTest ./systemd-analyze.nix {};
307+ systemd-binfmt = handleTestOn ["x86_64-linux"] ./systemd-binfmt.nix {};
307308 systemd-boot = handleTestOn ["x86_64-linux"] ./systemd-boot.nix {};
308309 systemd-confinement = handleTest ./systemd-confinement.nix {};
309310 systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
nixos/tests/systemd-binfmt.nixnew file+24
@@ -0,0 +1,24 @@
1+# Teach the kernel how to run armv7l and aarch64-linux binaries,
2+# and run GNU Hello for these architectures.
3+import ./make-test-python.nix ({ pkgs, ... }: {
4+ name = "systemd-binfmt";
5+ machine = {
6+ boot.binfmt.emulatedSystems = [
7+ "armv7l-linux"
8+ "aarch64-linux"
9+ ];
10+ };
11+
12+ testScript = let
13+ helloArmv7l = pkgs.pkgsCross.armv7l-hf-multiplatform.hello;
14+ helloAarch64 = pkgs.pkgsCross.aarch64-multiplatform.hello;
15+ in ''
16+ machine.start()
17+ assert "world" in machine.succeed(
18+ "${helloArmv7l}/bin/hello"
19+ )
20+ assert "world" in machine.succeed(
21+ "${helloAarch64}/bin/hello"
22+ )
23+ '';
24+})