nixdots/system/shared/boot/numlock.nix

33 lines
1,009 B
Nix
Raw Normal View History

2024-07-26 23:07:07 +00:00
{pkgs, ...}: {
2024-06-21 00:15:38 +00:00
boot.initrd.systemd = {
# Include setleds binary in the initrd
# (the nix store doesn't exists in there yet, so we need to include
# all of the necessary binaries ahead of time here)
extraBin = {
setleds = "${pkgs.kbd}/bin/setleds";
};
# Enable numlock in the early userspace (initrd)
# This will happen before we're asked for the disk decryption password
services."numlock" = {
enable = true;
description = "Activate Numlock";
2024-07-26 23:07:07 +00:00
wantedBy = ["initrd.target"];
2024-06-21 00:15:38 +00:00
# Delay disk decryption until this unit is started
2024-07-26 23:07:07 +00:00
before = ["systemd-cryptsetup@cryptfs.service"];
2024-06-21 00:15:38 +00:00
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
2024-07-26 23:07:07 +00:00
# This is essentially runs the same code as present in the
2024-06-21 00:15:38 +00:00
# mkinitcpio-numlock hook on Arch Linux (AUR).
script = ''
#!/bin/bash
for tty in /dev/tty{1..6}
do
/bin/setleds -D +num < "$tty";
done
'';
};
};
}