uninsane: clarify kernelPkgs config value

This commit is contained in:
Colin 2022-06-02 17:02:36 -07:00
parent 3a937e7a15
commit 4300cbbf8a

View File

@ -6,18 +6,10 @@
# enables non-free firmware # enables non-free firmware
hardware.enableRedistributableFirmware = true; hardware.enableRedistributableFirmware = true;
# XXX colin: these four statements were autogenerated and placed here: why? # i changed this becuse linux 5.10 didn't have rpi-400 device tree blob.
# boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" ]; # nixos-22.05 linux 5.15 DOES have these now.
# boot.initrd.kernelModules = [ ]; # it should be possible to remove this if desired, but i'm not sure how the rpi-specific kernel differs.
# boot.kernelModules = [ ]; # see: https://github.com/raspberrypi/linux
# boot.extraModulePackages = [ ];
# default nixos-21.11 kernel of 5.10 doesn't have the rpi-400 device tree blob.
# turns out 5.15, 5.16, 5.17 are all unable to boot the pi from usb (they fail to "direct load" certain broadcom firmware).
# linuxPackages_rpi4 uses 5.10, but supplies the pi-400 dtb & boots fine.
# boot.kernelPackages = pkgs.linuxPackages_latest;
# boot.kernelPackages = pkgs.linuxPackages_5_15;
# boot.kernelPackages = pkgs.linuxPackages_5_16;
boot.kernelPackages = pkgs.linuxPackages_rpi4; boot.kernelPackages = pkgs.linuxPackages_rpi4;
# NixOS defaults to grub: we don't want that. # NixOS defaults to grub: we don't want that.
@ -70,33 +62,33 @@
# XXX colin: this allows one to `systemctl halt` and then not remove power until the HDD has spun down. # XXX colin: this allows one to `systemctl halt` and then not remove power until the HDD has spun down.
# however, it doesn't work with reboot because systemd will spin the drive up again to read its reboot bin. # however, it doesn't work with reboot because systemd will spin the drive up again to read its reboot bin.
# a better solution would be to put the drive behind a powered USB hub (or get a SSD). # a better solution would be to put the drive behind a powered USB hub (or get a SSD).
systemd.services.diskguard = { # systemd.services.diskguard = {
description = "Safely power off spinning media"; # description = "Safely power off spinning media";
before = [ "shutdown.target" ]; # before = [ "shutdown.target" ];
wantedBy = [ "sysinit.target" ]; # wantedBy = [ "sysinit.target" ];
# old (creates dep loop, but works) # # old (creates dep loop, but works)
# before = [ "systemd-remount-fs.service" "shutdown.target" ]; # # before = [ "systemd-remount-fs.service" "shutdown.target" ];
# wantedBy = [ "systemd-remount-fs.service" ]; # # wantedBy = [ "systemd-remount-fs.service" ];
serviceConfig = { # serviceConfig = {
Type = "oneshot"; # Type = "oneshot";
RemainAfterExit = true; # RemainAfterExit = true;
ExecStart = "${pkgs.coreutils}/bin/true"; # ExecStart = "${pkgs.coreutils}/bin/true";
ExecStop = with pkgs; writeScript "diskguard" '' # ExecStop = with pkgs; writeScript "diskguard" ''
#!${bash}/bin/bash # #!${bash}/bin/bash
if ${procps}/bin/pgrep nixos-rebuild ; # if ${procps}/bin/pgrep nixos-rebuild ;
then # then
exit 0 # don't halt drives unless we're actually shutting down. maybe better way to do this (check script args?) # exit 0 # don't halt drives unless we're actually shutting down. maybe better way to do this (check script args?)
fi # fi
# ${coreutils}/bin/sync # # ${coreutils}/bin/sync
# ${util-linux}/bin/mount -o remount,ro /nix/store # # ${util-linux}/bin/mount -o remount,ro /nix/store
# ${util-linux}/bin/mount -o remount,ro / # # ${util-linux}/bin/mount -o remount,ro /
# -S 1 retracts the spindle after 5 seconds of idle # # -S 1 retracts the spindle after 5 seconds of idle
# -B 1 spins down the drive after <vendor specific duration> # # -B 1 spins down the drive after <vendor specific duration>
${hdparm}/sbin/hdparm -S 1 -B 1 /dev/sda # ${hdparm}/sbin/hdparm -S 1 -B 1 /dev/sda
# TODO: monitor smartmonctl until disk is idle? or try hdparm -Y # # TODO: monitor smartmonctl until disk is idle? or try hdparm -Y
# ${coreutils}/bin/sleep 20 # # ${coreutils}/bin/sleep 20
# exec ${util-linux}/bin/umount --all -t ext4,vfat,ext2 # # exec ${util-linux}/bin/umount --all -t ext4,vfat,ext2
''; # '';
}; # };
}; # };
} }