mirror of
https://github.com/Username404-59/Dotfiles-NixOS.git
synced 2026-07-03 12:58:07 +02:00
Add a machines directory to replace local.nix
+ detect if my device is a laptop
This commit is contained in:
parent
eb797005f7
commit
d832db0455
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/hardware-configuration.nix
|
||||
tamal/.silo
|
||||
@ -48,15 +48,21 @@ let
|
||||
localPackagesOverlay
|
||||
];
|
||||
};
|
||||
|
||||
isLaptop =
|
||||
let
|
||||
powerSupplyDir = /sys/class/power_supply;
|
||||
in
|
||||
builtins.pathExists powerSupplyDir && lib.any (name: lib.hasPrefix "BAT" name) (builtins.attrNames (builtins.readDir powerSupplyDir));
|
||||
in
|
||||
{
|
||||
nixpkgs.pkgs = pkgs; # Uses the nixtamal nixpkgs
|
||||
_module.args.nixtamal = nixtamal;
|
||||
_module.args.isLaptop = isLaptop;
|
||||
|
||||
imports =
|
||||
[
|
||||
./workarounds.nix
|
||||
./local.nix
|
||||
./hardware-configuration.nix # Results of the hardware scan ("nixos-generate-config" command)
|
||||
./modules/filesystems.nix
|
||||
"${nixtamal.home-manager}/nixos"
|
||||
@ -75,6 +81,10 @@ in
|
||||
|
||||
./common/ollama-config.nix
|
||||
|
||||
./machines/${
|
||||
if isLaptop then "laptop" else "desktop"
|
||||
}/local.nix
|
||||
|
||||
# ISO installer building stuff:
|
||||
./ISO/iso.nix
|
||||
];
|
||||
@ -126,7 +136,7 @@ in
|
||||
};
|
||||
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit nixtamal localPackagesOverlay;
|
||||
inherit nixtamal localPackagesOverlay isLaptop;
|
||||
};
|
||||
home-manager.users.doggo = import ./home/doggo/doggo.nix;
|
||||
|
||||
|
||||
@ -12,8 +12,43 @@ let
|
||||
mocha = {
|
||||
peach = "rgb(fab387)";
|
||||
};
|
||||
|
||||
find_monitor = id: "$(hyprctl monitors -j | jq -r '.[] | select(.id==${builtins.toString id}) | .name')";
|
||||
|
||||
backgrounds_commands = [
|
||||
"swaybg -i '${./backgrounds/ubuntu_budgie_wallpaper1.jpg}' -o ${find_monitor 0}"
|
||||
"murale '/disk2/MemoryRebootHatsune&Shrek.avi' -o ${find_monitor 1} --mpv-options '${mpv_options}'" # TODO: Make nixtamal download it with yt-dlp
|
||||
];
|
||||
|
||||
# Start(/stop) my backgrounds on (un)plug
|
||||
watch-ac-plug = pkgs.writeShellApplication {
|
||||
name = "watch-ac-plug";
|
||||
runtimeInputs = [ pkgs.dbus pkgs.gawk ];
|
||||
text = ''
|
||||
dbus-monitor --system "type='signal',interface='org.freedesktop.DBus.Properties',path='/org/freedesktop/UPower'" |
|
||||
while read -r line; do
|
||||
if echo "$line" | grep -q "OnBattery"; then
|
||||
read -r _ state
|
||||
if echo "$state" | grep -q "true"; then
|
||||
${builtins.concatStringsSep " && " (builtins.map (cmd: "pkill -f '.*${cmd}'") backgrounds_commands)}
|
||||
else
|
||||
${builtins.concatStringsSep " && " (builtins.map (cmd: "${uwsm} ${cmd}") backgrounds_commands)}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
systemd.user.services.watch-ac-plug = lib.mkIf isLaptop {
|
||||
Unit.Description = "Start/stop my backgrounds on AC plug/unplug";
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
Service = {
|
||||
ExecStart = "${watch-ac-plug}/bin/watch-ac-plug";
|
||||
Restart = "always";
|
||||
};
|
||||
};
|
||||
|
||||
wayland.windowManager.hyprland = {
|
||||
enable = true;
|
||||
systemd = {
|
||||
@ -24,30 +59,36 @@ in
|
||||
];
|
||||
|
||||
settings = {
|
||||
monitor = if !isLaptop then [
|
||||
{ output = "DP-3"; mode = "2560x1440@144"; position = "0x0"; scale = 1; vrr = 2; }
|
||||
{ output = "HDMI-A-4"; mode = "1920x1080@77"; position = "-1920x128"; scale = 1; }
|
||||
] else [
|
||||
{
|
||||
output = "eDP-1"; mode = "2880x1800@120"; position = "0x0"; scale = 1.5;
|
||||
monitor = [
|
||||
({
|
||||
# Desktop settings
|
||||
output = "DP-3";
|
||||
mode = "highres@highrr";
|
||||
position = "0x0"; scale = 1; vrr = 2;
|
||||
} // lib.optionalAttrs isLaptop {
|
||||
# Laptop settings
|
||||
output = "eDP-1";
|
||||
scale = 1.5;
|
||||
cm = "hdredid"; bitdepth = 10;
|
||||
min_luminance = 0.0; max_luminance = 2000;
|
||||
sdr_min_luminance = 0.005; sdr_max_luminance = 350; # 106?
|
||||
sdrsaturation = 1.0; # 1.175? 0.975?
|
||||
#sdrbrightness = 1.1; # 1.2625? 0.975?
|
||||
}
|
||||
})
|
||||
{ output = ""; mode = "highres@highrr"; position = if isLaptop then "auto-right" else "auto-left"; scale = 1; }
|
||||
];
|
||||
|
||||
|
||||
# AUTOSTART #
|
||||
on = {
|
||||
_args = [
|
||||
"hyprland.start"
|
||||
(lib.generators.mkLuaInline ''
|
||||
function()
|
||||
${if isLaptop then "-- " else ""}hl.exec_cmd("${uwsm} murale '/disk2/MemoryRebootHatsune&Shrek.avi' -o HDMI-A-4 --mpv-options '${mpv_options}'")
|
||||
hl.exec_cmd("${uwsm} swaybg ${
|
||||
if isLaptop then "-c 000000 -o '*'" else "-i '${./backgrounds/ubuntu_budgie_wallpaper1.jpg}' -o DP-3"
|
||||
}")
|
||||
hl.exec_cmd("${uwsm} swaybg -c 000000 -o '*'")
|
||||
${builtins.concatStringsSep "\n " (builtins.map (cmd:
|
||||
"hl.exec_cmd(\"${if isLaptop then "[ \"$(busctl get-property org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower OnBattery | awk '{print $2}')\" = \"true\" ] && " else ""}"
|
||||
+ "${uwsm} ${cmd}\")") backgrounds_commands)
|
||||
}
|
||||
hl.exec_cmd("${uwsm} ironbar")
|
||||
hl.exec_cmd("${uwsm} wl-paste --type text --watch cliphist store")
|
||||
hl.exec_cmd("${uwsm} wl-paste --type image --watch cliphist store")
|
||||
|
||||
67
local.nix
67
local.nix
@ -1,67 +0,0 @@
|
||||
{ config, lib, pkgs, functions, ...}:
|
||||
|
||||
let
|
||||
isLaptop = false;
|
||||
in
|
||||
{
|
||||
_module.args.isLaptop = isLaptop;
|
||||
home-manager.extraSpecialArgs = { inherit isLaptop; };
|
||||
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; [
|
||||
# Common modules
|
||||
] ++ (if !isLaptop then [
|
||||
# Desktop modules
|
||||
(functions.mkPatchedAuto nct6687d)
|
||||
r8125
|
||||
] else [
|
||||
# Laptop modules
|
||||
]);
|
||||
|
||||
boot.kernelModules = [
|
||||
# Common modules
|
||||
] ++ (if !isLaptop then [
|
||||
# Desktop modules
|
||||
"nct6687" # d disappears in actual module name
|
||||
"r8125" # replaces r8169
|
||||
] else [
|
||||
# Laptop modules
|
||||
]);
|
||||
|
||||
boot.blacklistedKernelModules = [] ++ (if !isLaptop then [
|
||||
"r8169"
|
||||
] else []);
|
||||
|
||||
# CRU screen overclocking
|
||||
hardware.firmware = lib.mkIf (!isLaptop) [
|
||||
(pkgs.runCommandLocal "PHL-edid-77hz" {} ''
|
||||
mkdir -p $out/lib/firmware/edid
|
||||
cp ${/disk2/Bunker/CRU/PHL_243V5_OC_77MHZ.bin} $out/lib/firmware/edid/PHL_243V5_OC_77MHZ.bin
|
||||
'')
|
||||
];
|
||||
|
||||
boot.kernelParams = lib.mkIf (!isLaptop) [
|
||||
"drm.edid_firmware=HDMI-A-4:edid/PHL_243V5_OC_77MHZ.bin"
|
||||
];
|
||||
|
||||
programs.coolercontrol.enable = !isLaptop;
|
||||
|
||||
boot.loader.limine.extraEntries = lib.mkIf (!isLaptop) ''
|
||||
/Windows
|
||||
protocol: efi
|
||||
path: label(windows_efi):/EFI/Microsoft/Boot/bootmgfw.efi
|
||||
'';
|
||||
|
||||
powerManagement.cpuFreqGovernor = if !isLaptop then "performance" else "schedutil";
|
||||
|
||||
services.auto-cpufreq = {
|
||||
enable = isLaptop;
|
||||
settings = {
|
||||
charger.turbo = "auto";
|
||||
battery.turbo = "never";
|
||||
};
|
||||
};
|
||||
|
||||
fileSystems."/".options = [ "noatime" ];
|
||||
|
||||
networking.hostName = if !isLaptop then "lizard" else "lizard-portable";
|
||||
}
|
||||
42
machines/desktop/local.nix
Normal file
42
machines/desktop/local.nix
Normal file
@ -0,0 +1,42 @@
|
||||
{ config, lib, pkgs, functions, ...}:
|
||||
|
||||
{
|
||||
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; [
|
||||
(functions.mkPatchedAuto nct6687d)
|
||||
r8125
|
||||
];
|
||||
|
||||
boot.kernelModules = [
|
||||
"nct6687" # d disappears in actual module name
|
||||
"r8125" # replaces r8169
|
||||
];
|
||||
|
||||
boot.blacklistedKernelModules = [
|
||||
"r8169"
|
||||
];
|
||||
|
||||
# CRU screen overclocking
|
||||
hardware.firmware = [
|
||||
(pkgs.runCommandLocal "PHL-edid-77hz" {} ''
|
||||
mkdir -p $out/lib/firmware/edid
|
||||
cp ${/disk2/Bunker/CRU/PHL_243V5_OC_77MHZ.bin} $out/lib/firmware/edid/PHL_243V5_OC_77MHZ.bin
|
||||
'')
|
||||
];
|
||||
|
||||
boot.kernelParams = [
|
||||
"drm.edid_firmware=HDMI-A-4:edid/PHL_243V5_OC_77MHZ.bin"
|
||||
];
|
||||
|
||||
programs.coolercontrol.enable = true;
|
||||
|
||||
boot.loader.limine.extraEntries = ''
|
||||
/Windows
|
||||
protocol: efi
|
||||
path: label(windows_efi):/EFI/Microsoft/Boot/bootmgfw.efi
|
||||
'';
|
||||
|
||||
powerManagement.cpuFreqGovernor = "performance";
|
||||
|
||||
networking.hostName = "lizard";
|
||||
}
|
||||
23
machines/laptop/local.nix
Normal file
23
machines/laptop/local.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{ config, ...}:
|
||||
|
||||
{
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; [];
|
||||
|
||||
boot.kernelModules = [];
|
||||
|
||||
boot.blacklistedKernelModules = [];
|
||||
|
||||
powerManagement.cpuFreqGovernor = "schedutil";
|
||||
|
||||
services.auto-cpufreq = {
|
||||
enable = true;
|
||||
settings = {
|
||||
charger.turbo = "auto";
|
||||
battery.turbo = "never";
|
||||
};
|
||||
};
|
||||
|
||||
services.upower.enable = true;
|
||||
|
||||
networking.hostName = "lizard-portable";
|
||||
}
|
||||
@ -2,8 +2,9 @@
|
||||
|
||||
{
|
||||
# Note: for f2fs, create it with "sudo mkfs.f2fs -l root -i -O extra_attr,flexible_inline_xattr,inode_checksum,sb_checksum,compression,lost_found /dev/sdxY"
|
||||
fileSystems."/".options = lib.mkIf (config.fileSystems."/".fsType == "f2fs")
|
||||
(lib.mkAfter [
|
||||
fileSystems."/".options = lib.mkMerge [
|
||||
[ "noatime" ]
|
||||
(lib.mkIf (config.fileSystems."/".fsType == "f2fs") (lib.mkAfter [
|
||||
"discard" # Better (on f2fs) than fstrim
|
||||
"X-fstrim.notrim" # To avoid fstrim
|
||||
"compress_algorithm=lzo-rle"
|
||||
@ -16,7 +17,8 @@
|
||||
"checkpoint_merge"
|
||||
"fsync_mode=posix"
|
||||
"nat_bits"
|
||||
]);
|
||||
]))
|
||||
];
|
||||
|
||||
services.fstrim.enable = true;
|
||||
|
||||
|
||||
@ -51,6 +51,12 @@
|
||||
|
||||
boot.kernelPatches = [ ];
|
||||
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
boot.kernelModules = [];
|
||||
|
||||
boot.blacklistedKernelModules = [];
|
||||
|
||||
services.scx = { # https://wiki.cachyos.org/configuration/sched-ext/#general-recommendations
|
||||
enable = true;
|
||||
scheduler = "scx_lavd";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user