Removed old stuff(dont use NixOS on desktop anymore) + update
This commit is contained in:
parent
859ffa55e8
commit
53750afbe3
47 changed files with 22 additions and 18286 deletions
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
namespace,
|
||||
system,
|
||||
target,
|
||||
format,
|
||||
virtual,
|
||||
systems,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with lib.${namespace}; let
|
||||
cfg = config.${namespace}.hardware.asahi;
|
||||
in {
|
||||
options.${namespace}.hardware.asahi = with types; {
|
||||
enable = mkBoolOpt false "Enable hardware support for Apple Silicon (M Chips)";
|
||||
imports = [
|
||||
inputs.apple-silicon-support.nixosModules.default
|
||||
({pkgs, ...}: {
|
||||
hardware.asahi = {
|
||||
peripheralFirmwareDirectory = ./firmware;
|
||||
useExperimentalGPUDriver = true; #deprecated
|
||||
#experimentalGPUInstallMode = "overlay";
|
||||
setupAsahiSound = true;
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
mesa-asahi-edge
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,88 +0,0 @@
|
|||
{
|
||||
config,
|
||||
namespace,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.${namespace}.hardware.battery;
|
||||
battery-path = "/sys/class/power_supply/${cfg.batteryName}";
|
||||
get-battery-level = "${pkgs.writeShellScriptBin "get-battery-level" ''
|
||||
cat ${battery-path}/capacity 2>/dev/null || echo "N/A"
|
||||
''}/bin/get-battery-level";
|
||||
get-status = "${pkgs.writeShellScriptBin "get-status" ''
|
||||
cat ${battery-path}/status 2>/dev/null || echo "Unknown"
|
||||
''}/bin/get-status";
|
||||
get-icon = "${pkgs.writeShellScriptBin "get-icon" ''
|
||||
BATTERY_LEVEL=$(${get-battery-level})
|
||||
STATUS=$(${get-status})
|
||||
if [[ "$BATTERY_LEVEL" == "N/A" ]]; then
|
||||
ICON=" "
|
||||
elif [[ "$STATUS" == "Charging" ]]; then
|
||||
if [[ $BATTERY_LEVEL -ge 90 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 80 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 70 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 60 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 50 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 40 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 30 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 20 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 10 ]]; then
|
||||
ICON=" "
|
||||
else
|
||||
ICON=" "
|
||||
fi
|
||||
else
|
||||
if [[ $BATTERY_LEVEL -ge 90 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 70 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 50 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 30 ]]; then
|
||||
ICON=" "
|
||||
elif [[ $BATTERY_LEVEL -ge 10 ]]; then
|
||||
ICON=" "
|
||||
else
|
||||
ICON=" "
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$ICON"
|
||||
''}/bin/get-icon";
|
||||
get-remaining-time = "${pkgs.writeShellScriptBin "get-remaining-time" ''
|
||||
REMAINING_ENERGY=$(cat ${battery-path}/${cfg.remainingEnergy})
|
||||
POWER_USAGE=$(cat ${battery-path}/${cfg.powerUsage})
|
||||
if [[ -n "$REMAINING_ENERGY" && -n "$POWER_USAGE" && "$POWER_USAGE" -ne 0 ]]; then
|
||||
TIME_LEFT=$(((REMAINING_ENERGY / POWER_USAGE)))
|
||||
MINUTES_LEFT=$(((( (REMAINING_ENERGY * 60) / POWER_USAGE )) - (TIME_LEFT * 60)))
|
||||
echo "$TIME_LEFT h $MINUTES_LEFT min"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
''}/bin/get-remaining-time";
|
||||
in {
|
||||
${namespace}.hardware.battery.scripts = {
|
||||
icon = get-icon;
|
||||
status = get-status;
|
||||
time = get-remaining-time;
|
||||
level = get-battery-level;
|
||||
labelAdaptive = "${pkgs.writeShellScriptBin "labelAdaptive" ''
|
||||
if [[ "$(${get-status})" == "Charging" ]]; then
|
||||
echo "$(${get-battery-level})% $(${get-icon})"
|
||||
else
|
||||
echo "$(${get-remaining-time}) $(${get-icon})"
|
||||
fi
|
||||
''}/bin/labelAdaptive";
|
||||
labelPercent = "${pkgs.writeShellScriptBin "labelPercent" ''
|
||||
echo "$(${get-battery-level})% $(${get-icon})"
|
||||
''}/bin/labelPercent";
|
||||
};
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
namespace,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with lib.${namespace}; let
|
||||
cfg = config.${namespace}.hardware.battery;
|
||||
in {
|
||||
options.${namespace}.hardware.battery = with types; {
|
||||
enable = mkBoolOpt false "If you have a battery in your hardware, enable this";
|
||||
batteryName = mkOpt str "BAT1" ''
|
||||
Put your battery name here. You can find it at "/sys/class/power_supply/"
|
||||
'';
|
||||
remainingEnergy = mkOpt str "charge_now" ''
|
||||
File in your battery, that tells the current amount of energy
|
||||
'';
|
||||
powerUsage = mkOpt str "current_now" ''
|
||||
File in your battery, that tells, how much energy your hardware is using
|
||||
'';
|
||||
scripts = {
|
||||
icon = mkOpt' str "";
|
||||
status = mkOpt' str "";
|
||||
time = mkOpt' str "";
|
||||
level = mkOpt' str "";
|
||||
labelAdaptive = mkOpt' str "";
|
||||
labelPercent = mkOpt' str "";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(import ./batteryStatus.nix {
|
||||
inherit config;
|
||||
inherit namespace;
|
||||
inherit pkgs;
|
||||
})
|
||||
{
|
||||
services.upower.enable = true;
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
namespace,
|
||||
system,
|
||||
target,
|
||||
format,
|
||||
virtual,
|
||||
systems,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with lib.${namespace}; let
|
||||
cfg = config.${namespace}.hardware.framework12;
|
||||
in {
|
||||
options.${namespace}.hardware.framework12 = with types; {
|
||||
enable = mkBoolOpt false "Enable hardware support for framework 12. P.s. you still need to import inputs.nixos-hardware.nixosModules.framework-12-13th-gen-intel yourself";
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
${namespace}.hardware = {
|
||||
tablet.enable = true;
|
||||
battery = {
|
||||
enable = true;
|
||||
batteryName = "BAT1";
|
||||
remainingEnergy = "charge_now";
|
||||
powerUsage = "current_now";
|
||||
};
|
||||
};
|
||||
# Ensure that the `pinctrl_tigerlake` kernel module is loaded before `soc_button_array`.
|
||||
# This is required for correcly switching to tablet mode when the display is folded back.
|
||||
boot.extraModprobeConfig = ''
|
||||
softdep soc_button_array pre: pinctrl_tigerlake
|
||||
'';
|
||||
boot.initrd.kernelModules = ["pinctrl_tigerlake"];
|
||||
# Patch the `udev` rules shipping with `iio-sensor-proxy` according to:
|
||||
# https://github.com/FrameworkComputer/linux-docs/blob/main/framework12/Ubuntu-25-04-accel-ubuntu25.04.md
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
iio-sensor-proxy = prev.iio-sensor-proxy.overrideAttrs (old: {
|
||||
postInstall = ''
|
||||
${old.postInstall or ""}
|
||||
sed -i 's/.*iio-buffer-accel/#&/' $out/lib/udev/rules.d/80-iio-sensor-proxy.rules
|
||||
'';
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
hardware.intel-gpu-tools.enable = true;
|
||||
services.thermald.enable = true;
|
||||
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
environment.systemPackages = [
|
||||
pkgs.framework-tool
|
||||
(pkgs.writeShellScriptBin "reset-tablet" ''
|
||||
sudo ${pkgs.framework-tool}/bin/framework_tool --tablet-mode tablet
|
||||
sudo ${pkgs.framework-tool}/bin/framework_tool --tablet-mode auto
|
||||
'')
|
||||
];
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
users = ["ALL"];
|
||||
commands = [
|
||||
{
|
||||
command = "${pkgs.framework-tool}/bin/framework_tool";
|
||||
options = ["NOPASSWD"];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
services.xserver.videoDrivers = ["modesetting"];
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
extraPackages = with pkgs; [
|
||||
# For modern Intel CPU's
|
||||
intel-media-driver # Enable Hardware Acceleration
|
||||
vpl-gpu-rt # Enable QSV
|
||||
];
|
||||
};
|
||||
environment.sessionVariables = {LIBVA_DRIVER_NAME = "iHD";};
|
||||
|
||||
users.groups.touchscreen = {};
|
||||
services.udev.extraRules = ''
|
||||
KERNEL=="event*", ATTRS{name}=="ILIT2901:00 222A:5539", SYMLINK+="touchscreen", MODE="0660", GROUP="touchscreen"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
namespace,
|
||||
system,
|
||||
target,
|
||||
format,
|
||||
virtual,
|
||||
systems,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with lib.${namespace}; let
|
||||
cfg = config.${namespace}.hardware.hibernation;
|
||||
in {
|
||||
options.${namespace}.hardware.hibernation = with types; {
|
||||
enable = mkBoolOpt false "Enable hibernation";
|
||||
swapFileOffset = mkOpt (nullOr int) null "Offset of swapfile. Calculate offset using https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Acquire_swap_file_offset";
|
||||
resumeDevice = mkOpt' path "/dev/disk/by-label/nixos";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
boot = {
|
||||
kernelParams =
|
||||
[
|
||||
"mem_sleep_default=deep"
|
||||
]
|
||||
#https://github.com/nix-community/disko/issues/651#issuecomment-2383741717
|
||||
++ optional (cfg.swapFileOffset != null) "resume_offset=${builtins.toString cfg.swapFileOffset}";
|
||||
resumeDevice = mkDefault cfg.resumeDevice;
|
||||
};
|
||||
services.logind.settings.Login = {
|
||||
HandleLidSwitch = mkDefault "suspend-then-hibernate";
|
||||
HandlePowerKey = mkDefault "suspend-then-hibernate";
|
||||
HandlePowerKeyLongPress = mkDefault "poweroff";
|
||||
};
|
||||
systemd.sleep.extraConfig = ''
|
||||
HibernateDelaySec=30m
|
||||
SuspendState=mem
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
namespace,
|
||||
system,
|
||||
target,
|
||||
format,
|
||||
virtual,
|
||||
systems,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with lib.${namespace}; let
|
||||
cfg = config.${namespace}.hardware.tablet;
|
||||
in {
|
||||
options.${namespace}.hardware.tablet = with types; {
|
||||
enable = mkBoolOpt false "Enable tablet module for hardware that supports it";
|
||||
path = mkOpt path "/run/tablet-mode-state" "Path with a file, where it's stated, whether tablet mode 'on' or 'off'";
|
||||
inputDevice = mkOpt' str "/dev/input/event4";
|
||||
onTabletModeEnable = mkOpt (listOf (attrsOf str)) [] "Actions to do when entering tablet mode";
|
||||
onTabletModeDisable = mkOpt (listOf (attrsOf str)) [] "Actions to do when exiting tablet mode";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# 1. System service for watching
|
||||
systemd.services = {
|
||||
tablet-mode-watcher = {
|
||||
description = "Watch for tablet mode changes";
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.writeShellScript "tablet-mode-eventd" ''
|
||||
if [ -f "${cfg.path}" ]; then
|
||||
in_tablet_mode=$(${pkgs.coreutils}/bin/cat "${cfg.path}")
|
||||
else
|
||||
echo 0 > "${cfg.path}"
|
||||
in_tablet_mode=0
|
||||
fi
|
||||
|
||||
stdbuf -oL -eL ${lib.getExe pkgs.libinput} debug-events --device "${cfg.inputDevice}" | while read -r line; do
|
||||
if [[ "$line" =~ switch\ tablet-mode\ state\ ([01]) ]]; then
|
||||
d="''${BASH_REMATCH[1]}"
|
||||
if [ "$d" -ne "$in_tablet_mode" ]; then
|
||||
in_tablet_mode=$d
|
||||
if [ "$d" -eq 1 ]; then
|
||||
${concatStringsSep "\n" (map (cmd: ''
|
||||
systemd-run --unit=tablet-on-${cmd.name} --collect sh -c '${cmd.command}'
|
||||
'')
|
||||
cfg.onTabletModeEnable)}
|
||||
echo "Tablet mode ON"
|
||||
echo 1 > "${cfg.path}"
|
||||
else
|
||||
${concatStringsSep "\n" (map (cmd: ''
|
||||
systemd-run --unit=tablet-off-${cmd.name} --collect sh -c '${cmd.command}'
|
||||
'')
|
||||
cfg.onTabletModeDisable)}
|
||||
echo "Tablet mode OFF"
|
||||
echo 0 > "${cfg.path}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
''}";
|
||||
Restart = "always";
|
||||
};
|
||||
wantedBy = ["graphical.target"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue