From 8b69dcc209afd893fc795b530529fc45bc535417 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 29 Apr 2024 19:58:25 +0100 Subject: [PATCH] pass entire config fragment to levitate, not just services to make it useful we need to be able to set packages, passwords, ssh keys etc --- NEWS | 21 ++++++++++++++++++++- examples/arhcive.nix | 12 ++++++++---- pkgs/levitate/default.nix | 8 +++++--- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 8bf5ea6..22d0eba 100644 --- a/NEWS +++ b/NEWS @@ -83,4 +83,23 @@ sponsoring this development (and funding the hardware) 2024-02-21 New port! Thanks to Raito Bezarius, Liminix now runs on the Zyxel NWA50AX, -an MT7621 (MIPS EL) dual radio WiFi AP. \ No newline at end of file +an MT7621 (MIPS EL) dual radio WiFi AP. + +2024-04-29 + +The setup for using `levitate` has changed: now it accepts an entire +config fragment, not just a list of services. Hopefully this makes it +a bit more useful :-) + + defaultProfile.packages = with pkgs; [ + ... + (levitate.override { + config = { + services = { + inherit (config.services) dhcpc sshd watchdog; + }; + defaultProfile.packages = [ mtdutils ]; + users.root.openssh.authorizedKeys.keys = secrets.root.keys; + }; + }) + ]; diff --git a/examples/arhcive.nix b/examples/arhcive.nix index f6bbea4..d062242 100644 --- a/examples/arhcive.nix +++ b/examples/arhcive.nix @@ -141,9 +141,13 @@ in rec { e2fsprogs mtdutils (levitate.override { - services = { - inherit (config.services) dhcpc sshd; - }; } - ) + config = { + services = { + inherit (config.services) dhcpc sshd watchdog; + }; + defaultProfile.packages = [ mtdutils ]; + users.root.openssh.authorizedKeys.keys = secrets.root.keys; + }; + }) ]; } diff --git a/pkgs/levitate/default.nix b/pkgs/levitate/default.nix index 207f8ea..8bbbfb6 100644 --- a/pkgs/levitate/default.nix +++ b/pkgs/levitate/default.nix @@ -4,7 +4,7 @@ , systemconfig , execline , lib -, services ? null +, config ? {} , liminix , pseudofile , pkgs @@ -12,6 +12,7 @@ let inherit (pseudofile) dir symlink; inherit (liminix.services) oneshot; + paramConfig = config; newRoot = "/run/maintenance"; sysconfig = let @@ -25,8 +26,8 @@ let emptyenv chroot . /bin/init ''; base = {...} : { - config = { - services = services // { + config = { + services = { banner = oneshot { name = "banner"; up = "cat /etc/banner > /dev/console"; @@ -60,6 +61,7 @@ let ../../modules/users.nix ../../modules/busybox.nix base + ({ ... } : paramConfig) ../../modules/s6 ]; };