2023-12-06 19:20:39 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2022-08-03 08:39:19 +00:00
|
|
|
|
|
|
|
|
|
{
|
2023-09-07 10:29:25 +00:00
|
|
|
|
imports = [
|
|
|
|
|
./x86_64.nix
|
|
|
|
|
];
|
|
|
|
|
|
2022-08-03 08:39:19 +00:00
|
|
|
|
boot.initrd.supportedFilesystems = [ "ext4" "btrfs" "ext2" "ext3" "vfat" ];
|
|
|
|
|
# useful emergency utils
|
|
|
|
|
boot.initrd.extraUtilsCommands = ''
|
|
|
|
|
copy_bin_and_libs ${pkgs.btrfs-progs}/bin/btrfstune
|
2023-11-08 10:55:47 +00:00
|
|
|
|
copy_bin_and_libs ${pkgs.util-linux}/bin/{cfdisk,lsblk,lscpu}
|
|
|
|
|
copy_bin_and_libs ${pkgs.gptfdisk}/bin/{cgdisk,gdisk}
|
|
|
|
|
copy_bin_and_libs ${pkgs.smartmontools}/bin/smartctl
|
|
|
|
|
copy_bin_and_libs ${pkgs.e2fsprogs}/bin/resize2fs
|
2023-11-15 20:41:41 +00:00
|
|
|
|
'' + lib.optionalString pkgs.stdenv.hostPlatform.isx86_64 ''
|
|
|
|
|
copy_bin_and_libs ${pkgs.nvme-cli}/bin/nvme # doesn't cross compile
|
2022-08-03 08:39:19 +00:00
|
|
|
|
'';
|
2023-10-11 05:40:19 +00:00
|
|
|
|
boot.kernelParams = [
|
|
|
|
|
"boot.shell_on_fail"
|
|
|
|
|
#v experimental full pre-emption for hopefully better call/audio latency on moby.
|
|
|
|
|
# also toggleable at runtime via /sys/kernel/debug/sched/preempt
|
|
|
|
|
# defaults to preempt=voluntary
|
|
|
|
|
# "preempt=full"
|
|
|
|
|
];
|
2022-08-03 08:39:19 +00:00
|
|
|
|
# other kernelParams:
|
|
|
|
|
# "boot.trace"
|
|
|
|
|
# "systemd.log_level=debug"
|
|
|
|
|
# "systemd.log_target=console"
|
|
|
|
|
|
2024-02-01 16:21:46 +00:00
|
|
|
|
# moby has to run recent kernels (defined elsewhere).
|
|
|
|
|
# meanwhile, kernel variation plays some minor role in things like sandboxing (landlock) and capabilities.
|
|
|
|
|
# simpler to keep near the latest kernel on all devices,
|
|
|
|
|
# and also makes certain that any weird system-level bugs i see aren't likely to be stale kernel bugs.
|
|
|
|
|
# servo needs zfs though, which doesn't support every kernel.
|
|
|
|
|
boot.kernelPackages = lib.mkDefault pkgs.zfs.latestCompatibleLinuxPackages;
|
|
|
|
|
|
2024-04-05 04:42:33 +00:00
|
|
|
|
# TODO: remove after linux 6.9. see: <https://github.com/axboe/liburing/issues/1113>
|
|
|
|
|
# - <https://github.com/neovim/neovim/issues/28149>
|
|
|
|
|
# - <https://git.kernel.dk/cgit/linux/commit/?h=io_uring-6.9&id=e5444baa42e545bb929ba56c497e7f3c73634099>
|
|
|
|
|
# when removing, try starting and suspending (ctrl+z) two instances of neovim simultaneously.
|
|
|
|
|
# if the system doesn't freeze, then this is safe to remove.
|
|
|
|
|
# added 2024-04-04
|
|
|
|
|
sane.user.fs.".profile".symlink.text = lib.mkBefore ''
|
|
|
|
|
export UV_USE_IO_URING=0
|
|
|
|
|
'';
|
|
|
|
|
|
2022-08-03 08:39:19 +00:00
|
|
|
|
# hack in the `boot.shell_on_fail` arg since that doesn't always seem to work.
|
|
|
|
|
boot.initrd.preFailCommands = "allowShell=1";
|
|
|
|
|
|
|
|
|
|
# default: 4 (warn). 7 is debug
|
|
|
|
|
boot.consoleLogLevel = 7;
|
|
|
|
|
|
|
|
|
|
boot.loader.grub.enable = lib.mkDefault false;
|
|
|
|
|
boot.loader.generic-extlinux-compatible.enable = lib.mkDefault true;
|
|
|
|
|
|
|
|
|
|
# non-free firmware
|
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
|
|
2023-12-01 13:18:05 +00:00
|
|
|
|
# default is 252274, which is too low particularly for servo.
|
|
|
|
|
# manifests as spurious "No space left on device" when trying to install watches,
|
|
|
|
|
# e.g. in dyn-dns by `systemctl start dyn-dns-watcher.path`.
|
|
|
|
|
# see: <https://askubuntu.com/questions/828779/failed-to-add-run-systemd-ask-password-to-directory-watch-no-space-left-on-dev>
|
|
|
|
|
boot.kernel.sysctl."fs.inotify.max_user_watches" = 1048576;
|
|
|
|
|
|
2022-08-03 08:39:19 +00:00
|
|
|
|
# powertop will default to putting USB devices -- including HID -- to sleep after TWO SECONDS
|
|
|
|
|
powerManagement.powertop.enable = false;
|
2023-09-08 05:37:56 +00:00
|
|
|
|
# linux CPU governor: <https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt>
|
2023-09-08 23:37:21 +00:00
|
|
|
|
# - options:
|
|
|
|
|
# - "powersave" => force CPU to always run at lowest supported frequency
|
|
|
|
|
# - "performance" => force CPU to always run at highest frequency
|
|
|
|
|
# - "ondemand" => adjust frequency based on load
|
|
|
|
|
# - "conservative" (ondemand but slower to adjust)
|
|
|
|
|
# - "schedutil"
|
|
|
|
|
# - "userspace"
|
|
|
|
|
# - not all options are available for all platforms
|
|
|
|
|
# - intel (intel_pstate) appears to manage scaling w/o intervention/control from the OS.
|
|
|
|
|
# - AMD (acpi-cpufreq) appears to manage scaling via the OS *or* HW. but the ondemand defaults never put it to max hardware frequency.
|
|
|
|
|
# - qualcomm (cpufreq-dt) appears to manage scaling *only* via the OS. ondemand governor exercises the full range.
|
|
|
|
|
# - query details with `sudo cpupower frequency-info`
|
2023-09-08 05:37:56 +00:00
|
|
|
|
powerManagement.cpuFreqGovernor = "ondemand";
|
2022-08-03 08:39:19 +00:00
|
|
|
|
|
2023-05-19 00:01:40 +00:00
|
|
|
|
services.logind.extraConfig = ''
|
2023-12-17 21:08:16 +00:00
|
|
|
|
# see: `man logind.conf`
|
|
|
|
|
# don’t shutdown when power button is short-pressed (commonly done an accident, or by cats).
|
|
|
|
|
# but do on long-press: useful to gracefully power-off server.
|
|
|
|
|
HandlePowerKey=lock
|
|
|
|
|
HandlePowerKeyLongPress=poweroff
|
|
|
|
|
HandleLidSwitch=lock
|
2023-05-19 00:01:40 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2022-08-03 08:39:19 +00:00
|
|
|
|
# services.snapper.configs = {
|
|
|
|
|
# root = {
|
|
|
|
|
# subvolume = "/";
|
|
|
|
|
# extraConfig = {
|
|
|
|
|
# ALLOW_USERS = "colin";
|
|
|
|
|
# };
|
|
|
|
|
# };
|
|
|
|
|
# };
|
|
|
|
|
# services.snapper.snapshotInterval = "daily";
|
|
|
|
|
}
|