Made it work

This commit is contained in:
2025-08-30 21:19:51 +02:00
parent fdbaf09146
commit 75d30efc6c
23 changed files with 148 additions and 1356 deletions

View File

@@ -1,4 +1,4 @@
{ pkgs, config, lib, ... }:
{ config, lib, ... }:
let
inherit (lib) mkOption types;
@@ -8,22 +8,8 @@ in
options.batMode = mkOption {
type = types.enum [ "single" "double" ];
default = "single";
description = "Select 'single' for one battery and 'double' for dual setup";
};
# Dont run a tandem with tlp
#options.services.auto-cpufreq.enable = true;
#options.services.auto-cpufreq.settings = {
# battery = {
# governor = "powersave";
# turbo = "never";
# };
# charger = {
# governor = "performance";
# turbo = "auto";
# };
#};
config = {
powerManagement.powertop.enable = true;
services.upower = {
@@ -34,7 +20,6 @@ in
percentageCritical = 20;
percentageAction = 10;
#percentageAction = "PowerOff";
criticalPowerAction = "PowerOff"; # This can destroy work
usePercentageForPolicy = true;
};
@@ -42,33 +27,20 @@ in
services.tlp = if config.batMode == "single" then {
enable = true;
settings = {
#Optional helps save long term battery health
# Going almost full because the other bat is also charged
# 0 NEW first
START_CHARGE_THRESH_BAT0 = 65;
STOP_CHARGE_THRESH_BAT0 = 85;
CPU_SCALING_GOVERNOR_ON_AC = "performance";
#CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
#CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_MIN_PERF_ON_AC = 0;
CPU_MAX_PERF_ON_AC = 100;
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 65;
};
} else {
enable = true;
settings = {
# Have to keep it this way or
# Otherwise the buil in stop at 5% stops worky
# The problem is here that only the second battery gets seen from the charging cap
# Workaround. Just charge the battery when you use it and then turn manually the battery off
# I mean it is the state you generate now that you can use on any laptop. so
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
@@ -80,11 +52,11 @@ in
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 75;
# 0 NEW first
# 0 is first
START_CHARGE_THRESH_BAT0 = 60;
STOP_CHARGE_THRESH_BAT0 = 85;
# 1 OLD second
# 1 is second
START_CHARGE_THRESH_BAT1 = 60;
STOP_CHARGE_THRESH_BAT1 = 85;
};

View File

@@ -1,28 +0,0 @@
{ config, lib, ... }:
let
inherit (lib) mkOption types;
in
{
options.bootMode = mkOption {
type = types.enum [ "uefi" "legacy" ];
default = "uefi";
description = "Select boot mode: 'uefi' or 'legacy'.";
};
config = {
boot.consoleLogLevel = 0;
boot.kernelParams = [ "quiet" "udev.log_level=3" ];
boot.loader = if config.bootMode == "uefi" then {
efi.canTouchEfiVariables = true;
systemd-boot.enable = true;
timeout = 0;
} else {
grub.enable = true;
grub.device = "/dev/sda"; # <- replace with actual target disk
timeout = 0;
};
};
}

View File

@@ -1,20 +0,0 @@
{ pkgs, ... }:
{
########## TEsting
# Load nvidia driver for Xorg and Wayland
services.steam.enable = true;
services.xserver.videoDrivers = ["nvidia"];
# Enable OpenGL
# Optional nvidia
hardware.graphics = {
enable = true;
};
hardware.nvidia = {
modesetting.enable = true;
open = false;
};
};

View File

@@ -0,0 +1,17 @@
{ config, ... }:
{
hardware.graphics = {
enable = true;
};
services.xserver.videoDrivers = ["nvidia"];
nixpkgs.config.cudaSupport = true;
hardware.enableAllFirmware = true;
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
open = false;
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
}

View File

@@ -1,21 +0,0 @@
{ pkgs, ... }:
{
# Enable common container config files in /etc/containers
# virtualisation.containers.enable = true;
# virtualisation = {
# podman = {
# enable = true;
# dockerSocket.enable = true;
# dockerCompat = true;
# defaultNetwork.settings.dns_enabled = true;
# };
# };
#
# # Useful other development tools
# environment.systemPackages = with pkgs; [
# dive # look into docker image layers
# podman-tui # status of containers in the terminal
# docker-compose # start group of containers for dev
# ];
virtualisation.docker.enable = true;
}

View File

@@ -1,58 +0,0 @@
{ pkgs, ... }:
{
# Experiments with services
systemd = {
timers."sync-manage-hourly" = {
enable = false;
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "10s"; # Start 10 seconds after boot
OnUnitActiveSec = "1h"; # Repeat every hour
Unit = "sync-manage.service"; # Points to the service unit
};
};
services = {
"shutdown-script" = {
enable = false;
description = "Run custom script on shutdown";
after = [ "shutdown.target" ]; # Ensure it runs during shutdown
script = "/home/jonas/projects/scripts/check_git.sh"; # Specify the path to your script
serviceConfig = {
Type = "oneshot";
User = "jonas"; # Run as jonas
WorkingDirectory = "/home/jonas"; # Set working directory to jonas' home
execStop = "/home/jonas/projects/scripts/check_git.sh"; # Specify the path to your script
# To ensure the script finishes before the system powers off
TimeoutStopSec = "30"; # You can adjust this if necessary
};
# To ensure the script finishes before the system powers off
};
"sync-manage" = {
script = ''
# Run the script from jonas' home directory
/home/jonas/projects/scripts/sync_manage.sh
'';
serviceConfig = {
Type = "oneshot";
User = "jonas"; # Run as jonas
WorkingDirectory = "/home/jonas"; # Set working directory to jonas' home
};
};
"sync-manage-shutdown" = {
enable = false;
script = ''
# Check if the system is connected to Wi-Fi
/home/jonas/projects/scripts/sync_manage.sh
'';
serviceConfig = {
Type = "oneshot";
User = "jonas"; # Run as jonas
ExecStop = "/usr/bin/true";
RemainAfterExit = true;
};
};
};
};
}

View File

@@ -0,0 +1,39 @@
{ inputs, ... }:
{
imports = [
inputs.xremap-flake.nixosModules.default
];
services.xremap = {
withHypr = true;
userName = "jonas";
config = {
modmap = [
{
name = "Capslock to esc and ctrl";
remap = {
"CAPSLOCK" = {
"alone" = "ESC";
"held" = "CTRL_L";
};
"ESC" = "CAPSLOCK";
};
}
{
name = "Switch super and alt";
remap = {
"SUPER_L" = {
"alone" = "ALT_L";
"held" = "ALT_L";
};
"ALT_L" = {
"alone" = "SUPER_L";
"held" = "SUPER_L";
};
};
}
];
};
};
}