mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-12-23 02:36:05 +01:00
print info during boot
This commit is contained in:
parent
470a50d903
commit
ffb28bb11a
@ -5,6 +5,8 @@
|
||||
./dns.nix
|
||||
# Nix garbage collection.
|
||||
./nix-gc.nix
|
||||
# Display contact information during boot.
|
||||
./initrd-contact-info.nix
|
||||
];
|
||||
|
||||
# Firmware.
|
||||
|
119
modules/initrd-contact-info.nix
Normal file
119
modules/initrd-contact-info.nix
Normal file
@ -0,0 +1,119 @@
|
||||
# Display contact information during boot. https://discourse.nixos.org/t/display-contact-info-in-nixos-boot-stage-1/38118/4
|
||||
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
contact_name = "Daniel Langbein";
|
||||
# TODO: move phone number to secret file
|
||||
contact_phone = "+49 xxx yyy";
|
||||
contact_mail = "daniel@systemli.org";
|
||||
|
||||
# https://wiki.nixos.org/wiki/Shell_Scripts
|
||||
contact-info-str = pkgs.stdenv.mkDerivation rec {
|
||||
name = "Contact information string";
|
||||
# disable unpackPhase etc
|
||||
phases = "buildPhase";
|
||||
builder = pkgs.writeShellScript "builder.sh" ''
|
||||
set -eu -o pipefail
|
||||
echo -e "If found, please contact:\n${contact_name}\n${contact_phone}\n${contact_mail}" \
|
||||
| cowsay --bold --aurora -f dragon > $out
|
||||
'';
|
||||
nativeBuildInputs = with pkgs; [ coreutils neo-cowsay ];
|
||||
PATH = lib.makeBinPath nativeBuildInputs;
|
||||
};
|
||||
|
||||
contact-info-img = pkgs.stdenv.mkDerivation rec{
|
||||
name = "Contact information image";
|
||||
nativeBuildInputs = with pkgs; [ imagemagick liberation_ttf ];
|
||||
phases = "installPhase";
|
||||
# magick add label: https://imagemagick.org/Usage/text/#label
|
||||
# magick font list: magick -list font | grep Font
|
||||
installPhase = ''
|
||||
set -eu -o pipefail
|
||||
mkdir -p $out
|
||||
#export XDG_CACHE_HOME="$out/.cache"
|
||||
magick -background black -fill 'hsb(120, 255, 63.75)' -font ${pkgs.liberation_ttf}/share/fonts/truetype/LiberationSans-Regular.ttf -pointsize 92 'label:If found, please contact:\n${contact_name}\n${contact_phone}\n${contact_mail}' $out/img.png
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
# Plymouth boot splash screen.
|
||||
# TODO: Only on graphical installations!
|
||||
#
|
||||
# To see the splash screen. https://wiki.archlinux.org/title/Plymouth#Installation
|
||||
#boot.kernelParams = [ "splash" ];
|
||||
#
|
||||
boot.plymouth = lib.mkIf (config.boot.initrd.systemd.enable) {
|
||||
enable = true;
|
||||
#theme = "breeze";
|
||||
logo = "${contact-info-img}/img.png";
|
||||
};
|
||||
|
||||
# Print contact info as text during boot.
|
||||
boot.initrd.preDeviceCommands = lib.mkIf (! config.boot.initrd.systemd.enable) ''
|
||||
cat <<'EOF'
|
||||
${builtins.readFile contact-info-str}
|
||||
EOF
|
||||
'';
|
||||
|
||||
# TODO: cleanup
|
||||
|
||||
#
|
||||
# TODO: systemd service output is not displayed during boot. onyl [info] service xxx started
|
||||
#
|
||||
|
||||
# # https://github.com/oxalica/nixpkgs/blob/3562c1d5c6ff868924fe95ba7b51344f3c141311/nixos/modules/config/console.nix#L158
|
||||
# boot.initrd.systemd.storePaths = [
|
||||
# "${config.boot.initrd.systemd.package.kbd}/bin/some-foo-package"
|
||||
# ];
|
||||
#
|
||||
# boot.initrd.systemd.services."If-found-please-send-email-to___${mail}___" = lib.mkIf (config.boot.initrd.systemd.enable) {
|
||||
# description = "Display part of the contact information inside service name";
|
||||
# wantedBy = [ "initrd.target" ];
|
||||
# after = [ "systemd-vconsole-setup.service" ];
|
||||
# before = [ "cryptsetup-pre.target" "local-fs-pre.target" ];
|
||||
# unitConfig.DefaultDependencies = "no";
|
||||
# serviceConfig.Type = "oneshot";
|
||||
# script = ''
|
||||
# wall TESTING-SOMETHING-OUT
|
||||
# '';
|
||||
# };
|
||||
#
|
||||
# # Soruces:
|
||||
# # - https://discourse.nixos.org/t/zfs-rollback-not-working-using-boot-initrd-systemd/37195/3
|
||||
# # - https://github.com/cole-h/nixos-config/blob/26f77d5d24e5859a1bb690cff63371d1ebf7d707/hosts/nixos/scadrial/modules/boot/remote-unlock.nix#L57-L69
|
||||
# boot.initrd.systemd.services."contact-info" = lib.mkIf (config.boot.initrd.systemd.enable) {
|
||||
# description = "Display contact information";
|
||||
# wantedBy = [
|
||||
# "initrd.target"
|
||||
# ];
|
||||
# after = [
|
||||
# "systemd-vconsole-setup.service"
|
||||
# ];
|
||||
# before = [
|
||||
# # Flowchart displaying the ordering of targets: https://www.freedesktop.org/software/systemd/man/latest/bootup.html
|
||||
# # cryptsetup-pre.target and local-fs-pre.target don't depend on each other but are instead orthogonal
|
||||
#
|
||||
# # This passive target unit may be pulled in by services that want to run before any encrypted block device is set up.
|
||||
# # https://www.freedesktop.org/software/systemd/man/systemd.special#cryptsetup-pre.target
|
||||
# "cryptsetup-pre.target"
|
||||
#
|
||||
# # This target unit is automatically ordered before all local mount points marked with auto.
|
||||
# # https://www.freedesktop.org/software/systemd/man/systemd.special#local-fs-pre.target
|
||||
# "local-fs-pre.target"
|
||||
#
|
||||
# # If the root device can be mounted at /sysroot, the sysroot.mount unit becomes active and initrd-root-fs.target is reached.
|
||||
# # https://man7.org/linux/man-pages/man7/bootup.7.html
|
||||
# #"sysroot.mount"
|
||||
# ];
|
||||
## path = with pkgs; [
|
||||
## neo-cowsay
|
||||
## ];
|
||||
# unitConfig.DefaultDependencies = "no";
|
||||
# serviceConfig.Type = "oneshot";
|
||||
# script = ''
|
||||
# cat <<'EOF'
|
||||
# ${builtins.readFile contact-info-str}
|
||||
# EOF
|
||||
# '';
|
||||
# };
|
||||
}
|
Loading…
Reference in New Issue
Block a user