aboutsummaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/systemd.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/base/systemd.nix b/base/systemd.nix
new file mode 100644
index 0000000..1bb0d0f
--- /dev/null
+++ b/base/systemd.nix
@@ -0,0 +1,50 @@
+# A slimmer systemd, without what a guest has no use for, as a module for
+# the base system:
+# nix-build pkgs/run-firecracker-vm --arg base '[ base/systemd.nix ]'
+# Built from source (no binary cache has it), on every nixpkgs bump, as are
+# dbus, against it instead of systemd-minimal (which comes in only with
+# dbus), and without X11 and AppArmor, and dbus-broker, which links
+# libsystemd. The initrd gets it, too. NixOS leaves out the units of
+# what the package doesn't have; coredump, which it doesn't, the base
+# system turns off already.
+{ config, lib, pkgs, ... }:
+{
+ systemd.package = pkgs.systemd.override {
+ withApparmor = false;
+ withCoredump = false; # elfutils
+ withCryptsetup = false;
+ withFido2 = false;
+ withHomed = false;
+ withImportd = false; # gnupg, openldap
+ withLibBPF = false;
+ withMachined = false;
+ withNspawn = false;
+ withPasswordQuality = false;
+ withPortabled = false;
+ withQrencode = false; # so no systemd-bsod, see below
+ withRemote = false; # microhttpd, gnutls
+ withRepart = false;
+ withSysupdate = false;
+ withTpm2Tss = false;
+ withVmspawn = false;
+ };
+ # NixOS's initrd has systemd-bsod (emergency messages full-screen, with a
+ # QR code), which systemd builds only with qrencode.
+ boot.initrd.systemd.suppressedUnits = [ "systemd-bsod.service" ];
+ boot.initrd.systemd.suppressedStorePaths = [
+ "${config.boot.initrd.systemd.package}/lib/systemd/systemd-bsod"
+ ];
+ # dbus against it, without X11 and AppArmor (which has no switch there).
+ services.dbus.dbusPackage = (pkgs.dbus.override {
+ systemdMinimal = config.systemd.package;
+ x11Support = false;
+ }).overrideAttrs (old: {
+ buildInputs = lib.remove pkgs.libapparmor old.buildInputs;
+ mesonFlags = map (f: if f == "-Dapparmor=enabled" then "-Dapparmor=disabled" else f) old.mesonFlags;
+ });
+ # It links libsystemd: with nixpkgs' systemd, the guest would have both.
+ services.dbus.brokerPackage = pkgs.dbus-broker.override {
+ systemd = config.systemd.package;
+ dbus = config.services.dbus.dbusPackage;
+ };
+}