2022-11-26 03:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
2023-11-10 18:48:06 +00:00
|
|
|
|
pkgs,
|
2022-11-26 03:23:53 +00:00
|
|
|
|
...
|
|
|
|
|
}:
|
2024-05-27 09:00:23 +00:00
|
|
|
|
let
|
2021-06-14 19:44:38 +00:00
|
|
|
|
psCfg = config.pub-solar;
|
|
|
|
|
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
|
2022-11-26 03:23:53 +00:00
|
|
|
|
in
|
|
|
|
|
{
|
2023-11-10 18:48:06 +00:00
|
|
|
|
pub-solar = {
|
|
|
|
|
terminal-life.full = true;
|
|
|
|
|
core.hibernation = {
|
2022-06-02 08:51:32 +00:00
|
|
|
|
enable = true;
|
2023-11-10 18:48:06 +00:00
|
|
|
|
resumeDevice = "/dev/mapper/cryptroot";
|
|
|
|
|
resumeOffset = 47366144;
|
2022-06-02 08:51:32 +00:00
|
|
|
|
};
|
2023-11-10 18:48:06 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Fix backlight for keyboard and brightness, adjust function key binding,
|
|
|
|
|
# intel_pstate for cpu schedutil
|
|
|
|
|
# For now, the radeon driver seems to work better than amdgpu with Radeon R9 M370X
|
|
|
|
|
# Explicitly set amdgpu support in place of radeon
|
|
|
|
|
# Source: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/southern-islands/default.nix
|
|
|
|
|
# Try again after https://lists.freedesktop.org/archives/amd-gfx/2023-March/090096.html lands
|
|
|
|
|
boot.kernelParams = [
|
|
|
|
|
"acpi_backlight=video"
|
|
|
|
|
"hid_apple.fnmode=2"
|
|
|
|
|
"intel_pstate=passive"
|
|
|
|
|
"radeon.si_support=0"
|
|
|
|
|
"amdgpu.si_support=1"
|
|
|
|
|
];
|
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
|
|
|
|
|
|
# Fix for Error switching console mode to 1: unsupported on startup
|
2024-05-27 09:00:23 +00:00
|
|
|
|
boot.loader.systemd-boot.consoleMode = lib.mkForce "0";
|
2023-11-10 18:48:06 +00:00
|
|
|
|
|
|
|
|
|
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
|
|
|
|
|
|
|
|
|
systemd.sleep.extraConfig = ''
|
|
|
|
|
HibernateMode=shutdown
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
|
cpu.intel.updateMicrocode = true;
|
|
|
|
|
facetimehd.enable = true;
|
|
|
|
|
opengl = {
|
2024-06-20 16:27:29 +00:00
|
|
|
|
extraPackages = with pkgs; [ intel-vaapi-driver ]; # i7-4870HQ older hardware like haswell (crystall well)
|
|
|
|
|
extraPackages32 = with pkgs.pkgsi686Linux; [ intel-vaapi-driver ];
|
2023-03-16 10:50:35 +00:00
|
|
|
|
};
|
2023-11-10 18:48:06 +00:00
|
|
|
|
};
|
2023-03-16 10:50:35 +00:00
|
|
|
|
|
2023-12-04 11:38:31 +00:00
|
|
|
|
services.fstrim.enable = true;
|
2023-11-20 17:43:09 +00:00
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
networking.hostName = "dumpyourvms";
|
|
|
|
|
|
|
|
|
|
services.resolved = {
|
|
|
|
|
enable = true;
|
|
|
|
|
extraConfig = ''
|
|
|
|
|
DNS=5.1.66.255#dot.ffmuc.net 185.150.99.255#dot.ffmuc.net 5.9.164.112#dns3.digitalcourage.de 89.233.43.71#unicast.censurfridns.dk 185.49.141.37#getdnsapi.net 2001:678:e68:f000::#dot.ffmuc.net 2001:678:ed0:f000::#dot.ffmuc.net 2a01:4f8:251:554::2#dns3.digitalcourage.de 2a01:3a0:53:53::0#unicast.censurfridns.dk 2a04:b900:0:100::38#getdnsapi.net
|
|
|
|
|
FallbackDNS=9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
|
|
|
|
|
Domains=~.
|
|
|
|
|
DNSOverTLS=yes
|
|
|
|
|
'';
|
|
|
|
|
};
|
2024-03-06 17:56:19 +00:00
|
|
|
|
services.tailscale = {
|
|
|
|
|
enable = true;
|
|
|
|
|
useRoutingFeatures = "client";
|
|
|
|
|
};
|
2023-12-17 21:48:55 +00:00
|
|
|
|
services.usbmuxd.enable = true;
|
2024-06-20 16:28:15 +00:00
|
|
|
|
|
|
|
|
|
#programs.droidcam.enable = true;
|
2024-05-27 09:00:23 +00:00
|
|
|
|
#services.mozillavpn.enable = true;
|
2023-11-10 18:48:06 +00:00
|
|
|
|
|
|
|
|
|
security.pki.certificateFiles = [ ./consul-agent-ca.pem ];
|
|
|
|
|
|
|
|
|
|
# Power off dedicated GPU, use only integrated Intel GPU to save battery
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/33915
|
|
|
|
|
# https://ubuntuforums.org/showthread.php?t=2409856
|
|
|
|
|
systemd.services."amd-hybrid-graphics-power-save" = {
|
|
|
|
|
path = [ pkgs.bash ];
|
|
|
|
|
description = "Power Off dedicated AMD Card to reduce power usage";
|
|
|
|
|
requires = [ "sys-kernel-debug.mount" ];
|
|
|
|
|
enable = true;
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "oneshot";
|
|
|
|
|
RemainAfterExit = true;
|
|
|
|
|
ExecStart = "${pkgs.bash}/bin/sh -c 'sleep 7 && if grep --quiet 'IGD:+' /sys/kernel/debug/vgaswitcheroo/switch; then echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch; fi'";
|
|
|
|
|
ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'";
|
2022-01-05 22:16:35 +00:00
|
|
|
|
};
|
2023-11-10 18:48:06 +00:00
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
};
|
2021-06-14 19:44:38 +00:00
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
# Increase console font size for HiDPI display
|
|
|
|
|
console = {
|
|
|
|
|
earlySetup = true;
|
|
|
|
|
font = lib.mkForce "ter-i32b";
|
|
|
|
|
packages = [ pkgs.terminus_font ];
|
|
|
|
|
};
|
2022-01-05 22:16:35 +00:00
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
# Thunderbolt tools
|
|
|
|
|
services.hardware.bolt.enable = true;
|
|
|
|
|
|
|
|
|
|
# Enable udev rules for gnupg smart cards
|
|
|
|
|
hardware.gpgSmartcards.enable = true;
|
|
|
|
|
|
2024-06-20 16:26:22 +00:00
|
|
|
|
hardware.keyboard.uhk.enable = true;
|
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
powerManagement = {
|
|
|
|
|
# Use new schedutil govenor
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/42330
|
|
|
|
|
# https://www.kernel.org/doc/html/v5.10/admin-guide/pm/cpufreq.html#schedutil
|
|
|
|
|
cpuFreqGovernor = lib.mkDefault "schedutil";
|
|
|
|
|
|
|
|
|
|
# brcmfmac being loaded during hibernation would inhibit a successful resume
|
|
|
|
|
# https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116.
|
|
|
|
|
# Also brcmfmac could randomly crash on resume from sleep.
|
|
|
|
|
# To hibernate successfully using the amdgpu driver, the dedicated GPU needs
|
|
|
|
|
# to be powered on.
|
|
|
|
|
powerUpCommands = lib.mkBefore (
|
|
|
|
|
"${pkgs.kmod}/bin/modprobe brcmfmac"
|
|
|
|
|
+ lib.optionalString (lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") " brcmfmac_wcc"
|
|
|
|
|
);
|
|
|
|
|
powerDownCommands = lib.mkBefore (
|
|
|
|
|
lib.optionalString (lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") "${pkgs.kmod}/bin/rmmod brcmfmac_wcc\n"
|
|
|
|
|
+ ''
|
|
|
|
|
${pkgs.kmod}/bin/rmmod brcmfmac
|
|
|
|
|
${pkgs.systemd}/bin/systemctl stop amd-hybrid-graphics-power-save.service
|
|
|
|
|
''
|
|
|
|
|
);
|
|
|
|
|
resumeCommands =
|
|
|
|
|
if config.systemd.services."amd-hybrid-graphics-power-save".enable == true then
|
|
|
|
|
''
|
|
|
|
|
${pkgs.systemd}/bin/systemctl start amd-hybrid-graphics-power-save.service
|
|
|
|
|
''
|
|
|
|
|
else
|
|
|
|
|
"";
|
|
|
|
|
};
|
2022-01-05 22:16:35 +00:00
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
# Change lid switch behaviour
|
|
|
|
|
services.logind.lidSwitch = "hibernate";
|
|
|
|
|
|
|
|
|
|
# TLP for power management
|
|
|
|
|
services.tlp = {
|
|
|
|
|
enable = true;
|
|
|
|
|
settings = {
|
|
|
|
|
CPU_SCALING_GOVERNOR_ON_AC = "performance";
|
|
|
|
|
CPU_SCALING_GOVERNOR_ON_BAT = "schedutil";
|
|
|
|
|
CPU_BOOST_ON_AC = 1;
|
|
|
|
|
CPU_BOOST_ON_BAT = 0;
|
2021-06-20 13:38:01 +00:00
|
|
|
|
};
|
2023-11-10 18:48:06 +00:00
|
|
|
|
};
|
2021-06-20 13:38:01 +00:00
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
services.udev.extraRules =
|
|
|
|
|
# Disable XHC1 wakeup signal to avoid resume getting triggered some time
|
|
|
|
|
# after suspend. Reboot required for this to take effect.
|
|
|
|
|
lib.optionalString (lib.versionAtLeast config.boot.kernelPackages.kernel.version "3.13")
|
|
|
|
|
''SUBSYSTEM=="pci", KERNEL=="0000:00:14.0", ATTR{power/wakeup}="disabled"'';
|
2024-08-19 10:38:46 +00:00
|
|
|
|
|
2023-11-10 18:48:06 +00:00
|
|
|
|
home-manager =
|
|
|
|
|
pkgs.lib.setAttrByPath
|
|
|
|
|
[
|
|
|
|
|
"users"
|
|
|
|
|
psCfg.user.name
|
|
|
|
|
]
|
|
|
|
|
{
|
|
|
|
|
# Custom device sway configs
|
|
|
|
|
xdg.configFile = {
|
|
|
|
|
"sway/config.d/10-applications.conf".source = ./.config/sway/config.d/applications.conf;
|
|
|
|
|
"sway/config.d/autostart.conf".source = ./.config/sway/config.d/autostart.conf;
|
|
|
|
|
"sway/config.d/10-custom-keybindings.conf".source = ./.config/sway/config.d/custom-keybindings.conf;
|
|
|
|
|
"sway/config.d/input-defaults.conf".source = ./.config/sway/config.d/input-defaults.conf;
|
|
|
|
|
"sway/config.d/screens.conf".source = ./.config/sway/config.d/screens.conf;
|
2021-06-14 19:44:38 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2023-11-10 18:48:06 +00:00
|
|
|
|
|
|
|
|
|
# WLAN frequency compliance (e.g. check for radar with DFS)
|
|
|
|
|
hardware.firmware = with pkgs; [ wireless-regdb ];
|
|
|
|
|
boot.extraModprobeConfig = ''
|
|
|
|
|
options cfg80211 ieee80211_regdom="DE"
|
|
|
|
|
|
|
|
|
|
# Enable the integrated GPU (iGPU) Intel i915 by default if present
|
|
|
|
|
options apple-gmux force_igd=y
|
2024-02-05 11:54:36 +00:00
|
|
|
|
|
|
|
|
|
# Enable HD-Audio Codec-Specific Models
|
|
|
|
|
# https://www.kernel.org/doc/html/latest/sound/hd-audio/models.html
|
|
|
|
|
options snd-hda-intel model=mbp11
|
|
|
|
|
|
|
|
|
|
# https://bbs.archlinux.org/viewtopic.php?pid=1445636#p1445636
|
|
|
|
|
#
|
|
|
|
|
options snd-hda-intel index=1
|
2023-11-10 18:48:06 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# This value determines the NixOS release from which the default
|
|
|
|
|
# settings for stateful data, like file locations and database versions
|
|
|
|
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
|
|
|
|
# this value at the release version of the first install of this system.
|
|
|
|
|
# Before changing this value read the documentation for this option
|
|
|
|
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
|
|
|
|
system.stateVersion = "21.05"; # Did you read the comment?
|
2021-06-14 19:44:38 +00:00
|
|
|
|
}
|