refactoring
This commit is contained in:
parent
dc2414a72a
commit
6a748eae80
5 changed files with 96 additions and 101 deletions
|
@ -8,7 +8,8 @@
|
|||
./razer-speaker-fix.nix
|
||||
./boot.nix
|
||||
./hardware.nix
|
||||
./packages
|
||||
./packages.nix
|
||||
./udev.nix
|
||||
|
||||
btrfs-conf
|
||||
|
||||
|
@ -150,62 +151,6 @@
|
|||
IdleActionSec=15m
|
||||
'';
|
||||
};
|
||||
services.udev = {
|
||||
extraRules = ''
|
||||
KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"
|
||||
DEVPATH=="/devices/virtual/misc/cpu_dma_latency", OWNER="root", GROUP="audio", MODE="0660"
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="ddcci*", RUN+="${pkgs.coreutils-full}/bin/chgrp video /sys/class/backlight/%k/brightness"
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="ddcci*", RUN+="${pkgs.coreutils-full}/bin/chmod a+w /sys/class/backlight/%k/brightness"
|
||||
ACTION=="add", SUBSYSTEM=="i2c-dev", ATTR{name}=="AMDGPU DM*", TAG+="ddcci", TAG+="systemd", ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
||||
ACTION=="add", SUBSYSTEM=="i2c-dev", ATTR{name}=="NVIDIA i2c adapter*", TAG+="ddcci", TAG+="systemd", ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
||||
SUBSYSTEM=="i2c", ACTION=="add", ATTR{name}=="AMDGPU DM aux hw bus 3", RUN+="${pkgs.bash}/bin/bash -c 'sleep 30; printf ddcci\ 0x37 > /sys/bus/i2c/devices/i2c-17/new_device'"
|
||||
'';
|
||||
packages = [
|
||||
pkgs.via
|
||||
pkgs.vial
|
||||
pkgs.ddcutil
|
||||
pkgs.game-devices-udev-rules
|
||||
pkgs.sane-airscan
|
||||
pkgs.utsushi
|
||||
pkgs.openrgb-with-all-plugins
|
||||
|
||||
pkgs.gnome-settings-daemon
|
||||
pkgs.gnome-keyring
|
||||
|
||||
(pkgs.writeTextFile {
|
||||
name = "on-battery";
|
||||
text = ''
|
||||
# Rule for when switching to battery
|
||||
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/60-onbattery.rules";
|
||||
})
|
||||
(pkgs.writeTextFile {
|
||||
name = "on-power";
|
||||
text = ''
|
||||
# Rule for when switching to ac
|
||||
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/61-onpower.rules";
|
||||
})
|
||||
(pkgs.writeTextFile {
|
||||
name = "hibernate-low-battery";
|
||||
text = ''
|
||||
# Suspend the system when battery level drops to 5% or lower
|
||||
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${pkgs.systemd}/bin/systemctl hibernate"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/99-hibernate-low-battery.rules";
|
||||
})
|
||||
(pkgs.writeTextFile {
|
||||
name = "on-battery-power-saver";
|
||||
text = ''
|
||||
# Switch to power-saver when battery below 50%
|
||||
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5][0-9]", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/62-power-save-battery.rules";
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
security = {
|
||||
polkit.enable = true;
|
||||
|
|
61
hosts/eddie/udev.nix
Normal file
61
hosts/eddie/udev.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
|
||||
services.udev = {
|
||||
extraRules = ''
|
||||
KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"
|
||||
DEVPATH=="/devices/virtual/misc/cpu_dma_latency", OWNER="root", GROUP="audio", MODE="0660"
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="ddcci*", RUN+="${pkgs.coreutils-full}/bin/chgrp video /sys/class/backlight/%k/brightness"
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="ddcci*", RUN+="${pkgs.coreutils-full}/bin/chmod a+w /sys/class/backlight/%k/brightness"
|
||||
ACTION=="add", SUBSYSTEM=="i2c-dev", ATTR{name}=="AMDGPU DM*", TAG+="ddcci", TAG+="systemd", ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
||||
ACTION=="add", SUBSYSTEM=="i2c-dev", ATTR{name}=="NVIDIA i2c adapter*", TAG+="ddcci", TAG+="systemd", ENV{SYSTEMD_WANTS}+="ddcci@$kernel.service"
|
||||
SUBSYSTEM=="i2c", ACTION=="add", ATTR{name}=="AMDGPU DM aux hw bus 3", RUN+="${pkgs.bash}/bin/bash -c 'sleep 30; printf ddcci\ 0x37 > /sys/bus/i2c/devices/i2c-17/new_device'"
|
||||
'';
|
||||
packages = [
|
||||
pkgs.via
|
||||
pkgs.vial
|
||||
pkgs.ddcutil
|
||||
pkgs.game-devices-udev-rules
|
||||
pkgs.sane-airscan
|
||||
pkgs.utsushi
|
||||
pkgs.openrgb-with-all-plugins
|
||||
|
||||
pkgs.gnome-settings-daemon
|
||||
pkgs.gnome-keyring
|
||||
|
||||
(pkgs.writeTextFile {
|
||||
name = "on-battery";
|
||||
text = ''
|
||||
# Rule for when switching to battery
|
||||
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/60-onbattery.rules";
|
||||
})
|
||||
(pkgs.writeTextFile {
|
||||
name = "on-power";
|
||||
text = ''
|
||||
# Rule for when switching to ac
|
||||
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/61-onpower.rules";
|
||||
})
|
||||
(pkgs.writeTextFile {
|
||||
name = "hibernate-low-battery";
|
||||
text = ''
|
||||
# Suspend the system when battery level drops to 5% or lower
|
||||
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${pkgs.systemd}/bin/systemctl hibernate"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/99-hibernate-low-battery.rules";
|
||||
})
|
||||
(pkgs.writeTextFile {
|
||||
name = "on-battery-power-saver";
|
||||
text = ''
|
||||
# Switch to power-saver when battery below 50%
|
||||
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5][0-9]", RUN+="${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver"
|
||||
'';
|
||||
destination = "/etc/udev/rules.d/62-power-save-battery.rules";
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue