experimental

This commit is contained in:
Grimmauld 2024-05-02 14:02:35 +02:00
parent 139bd596da
commit caf81af676
Signed by: Grimmauld
GPG Key ID: C2946668769F91FB
13 changed files with 115 additions and 50 deletions

View File

@ -10,7 +10,7 @@ let
local = mkOption { local = mkOption {
type = types.nonEmptyStr; type = types.nonEmptyStr;
default = "$HOME/" + (lib.strings.concatStrings (builtins.match "/*(.+)" config.remote)); default = "$HOME/" + (concatStrings (builtins.match "/*(.+)" config.remote));
description = "local path to sync"; description = "local path to sync";
}; };
}; };

View File

@ -4,7 +4,7 @@ let
screen = with lib; types.submodule { screen = with lib; types.submodule {
options = { options = {
fps = mkOption { fps = mkOption {
type = types.int; type = types.either types.int (types.nonEmptyListOf types.int);
default = 60; default = 60;
description = "max framerate of screen"; description = "max framerate of screen";
}; };

View File

@ -15,6 +15,12 @@ let
description = "set of commands to be run at sway startup"; description = "set of commands to be run at sway startup";
}; };
execAlways = mkOption {
type = types.listOf (types.either types.nonEmptyStr types.package);
default = [ ];
description = "set of commands to be run at sway reload";
};
extraConfig = mkOption { extraConfig = mkOption {
type = types.str; type = types.str;
default = ""; default = "";
@ -34,6 +40,34 @@ let
}; };
}; };
}); });
build_screen_def = fps_func: with lib; let
output_def = mapAttrsToList
(name: value:
"output ${value.id} mode ${value.mode}@${toString (fps_func value.fps)}Hz"
+ (optionalString (value.pos != null) " position ${value.pos}")
)
cfg.screens;
in ''
for pid in $(${pkgs.procps}/bin/pgrep sway -x)
do
uid=$(id -u $(${pkgs.procps}/bin/ps -o user= -p $pid))
export SWAYSOCK="/run/user/$uid/sway-ipc.$uid.$pid.sock"
if [[ -e "$SWAYSOCK" ]] ; then
echo "sock is $SWAYSOCK"
${config.programs.sway.package}/bin/swaymsg '${concatMapStrings (s: s + " ; ") output_def}'
fi
done
'';
inherit (lib) getExe;
fps_min = fps: with lib; if isInt fps then fps else (foldl' min 2147483647 fps);
fps_max = fps: with lib; if isInt fps then fps else (foldl' max 0 fps);
init_screens_min_fps = with lib; pkgs.writeShellScriptBin "init-screens-min"
(build_screen_def fps_min);
init_screens_max_fps = with lib; pkgs.writeShellScriptBin "init-screens-max"
(build_screen_def fps_max);
init_screens_auto = pkgs.writeShellScriptBin "init-screens-auto" "which run-on-ac && which run-on-bat && run-on-ac ${getExe init_screens_max_fps} && run-on-bat ${getExe init_screens_min_fps} || ${getExe init_screens_max_fps}";
in in
{ {
config = config =
@ -46,7 +80,7 @@ in
bar_config = '' bar_config = ''
bar { bar {
swaybar_command ${lib.getExe waybar_full} swaybar_command ${getExe waybar_full}
} }
''; '';
@ -60,15 +94,16 @@ in
let let
build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}"); build_definition_lines = mapAttrsToList (name: value: "set \$${name} ${value}");
build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}"); build_keybind_lines = mapAttrsToList (key: value: "bindsym ${key} ${value}");
build_exec_lines = map (item: "exec " + (if isString item then item else (getExe item))); build_exec_lines = e: map (item: "${e} " + (if isString item then item else (getExe item)));
build_mode_lines = mapAttrsToList (name: value: '' build_mode_lines = mapAttrsToList (name: value: ''
mode "${name}" { mode "${name}" {
${strings.concatLines (map (item: " " + item ) (build_conf value))}}''); ${concatLines (map (item: " " + item ) (build_conf value))}}'');
in in
([ ] ([ ]
++ (build_definition_lines sway_conf.definitions) ++ (build_definition_lines sway_conf.definitions)
++ (build_keybind_lines sway_conf.keybinds) ++ (build_keybind_lines sway_conf.keybinds)
++ (build_exec_lines sway_conf.autolaunch) ++ (build_exec_lines "exec" sway_conf.autolaunch)
++ (build_exec_lines "exec_always" sway_conf.execAlways)
++ (build_mode_lines sway_conf.modes) ++ (build_mode_lines sway_conf.modes)
++ optional (sway_conf.extraConfig != "") sway_conf.extraConfig ++ optional (sway_conf.extraConfig != "") sway_conf.extraConfig
); );
@ -76,12 +111,6 @@ in
sway_conf = lib.concatLines ( sway_conf = lib.concatLines (
(build_conf cfg.sway.config) (build_conf cfg.sway.config)
++ lib.optional cfg.sway.bar.enable bar_config ++ lib.optional cfg.sway.bar.enable bar_config
++ (lib.mapAttrsToList
(name: value:
"output ${value.id} mode ${value.mode}@${toString value.fps}Hz"
+ (lib.optionalString (value.pos != null) " position ${value.pos}")
)
cfg.screens)
); );
conf_path = "sway.conf"; conf_path = "sway.conf";
@ -89,11 +118,17 @@ in
with cfg; lib.mkIf (enable && sway.enable) { with cfg; lib.mkIf (enable && sway.enable) {
environment.etc."${conf_path}".text = sway_conf; environment.etc."${conf_path}".text = sway_conf;
grimmShared.sway.config.autolaunch = lib.singleton dbus-sway-environment; grimmShared.sway.config.execAlways = [
dbus-sway-environment
init_screens_auto
];
environment.systemPackages = [ environment.systemPackages = [
waybar_full waybar_full
dbus-sway-environment dbus-sway-environment
init_screens_min_fps
init_screens_max_fps
init_screens_auto
] ++ (with pkgs; [ ] ++ (with pkgs; [
procps procps
slurp slurp

View File

@ -1,6 +1,6 @@
{ {
imports = [ imports = [
./laptop.nix ./laptop.nix
./tlp.nix # ./tlp.nix
]; ];
} }

View File

@ -11,6 +11,8 @@ in
usbutils usbutils
opentabletdriver opentabletdriver
ddcutil ddcutil
python312Packages.py-cpuinfo
(writeShellScriptBin "lsiommu" ./lsiommu)
] ++ lib.optionals graphical [ ] ++ lib.optionals graphical [
ddcui ddcui
]; ];
@ -52,6 +54,7 @@ in
"mmio_stale_data=full,nosmt" "mmio_stale_data=full,nosmt"
"pcie_aspm=off" "pcie_aspm=off"
]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ]; ]; # "vfio-pci.ids=10de:1aeb,10de:2191,10de:1aed,10de:1aec" ];
loader.efi.canTouchEfiVariables = true;
initrd.availableKernelModules = [ initrd.availableKernelModules = [
"xhci_pci" "xhci_pci"
"ahci" "ahci"

View File

@ -1,23 +1,47 @@
{ pkgs, config, lib, system, ... }: { pkgs, config, lib, system, ... }:
let let
cfg = config.grimmShared; cfg = config.grimmShared;
perf_policy = lib.optional (lib.systems.elaborate system).isx86 config.boot.kernelPackages.x86_energy_perf_policy; inherit (lib) optionals optional optionalString concatLines getExe;
inherit (config.boot.kernelPackages) x86_energy_perf_policy cpupower;
enable_perf_policy = (lib.elem system x86_energy_perf_policy.meta.platforms) && false;
powersave = with pkgs; writeShellScriptBin "powersave-mode" (concatLines ([
"${getExe cpupower} frequency-set -g powersave -u 2000000" # clock speed
"${getExe pkgs.brightnessctl} s 20%" # display brightness
] ++ optionals enable_perf_policy [
"${getExe x86_energy_perf_policy} 15" # power save preference
"${getExe x86_energy_perf_policy} --turbo-enable 0" # disable turbo
] ++ optional cfg.sway.enable "init-screens-min"));
performance = pkgs.writeShellScriptBin "performance-mode" (concatLines ([
"${getExe cpupower} frequency-set frequency-set -g performance -u 5000000" # clock speed
"${getExe pkgs.brightnessctl} s 100%" # display brightness
] ++ optionals enable_perf_policy [
"${getExe x86_energy_perf_policy} 0" # performance preference
"${getExe x86_energy_perf_policy} --turbo-enable 1" # enable turbo
] ++ optional cfg.sway.enable "init-screens-max"));
in in
{ {
config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { config = with cfg; lib.mkIf (enable && laptop_hardware.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
acpi acpi
powertop powertop
] ++ lib.optionals graphical [ brightnessctl
cpupower
powersave
performance
] ++ optionals graphical [
tlpui tlpui
] ++ perf_policy; ] ++ optional enable_perf_policy x86_energy_perf_policy;
powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power"; powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power";
powerManagement.cpuFreqGovernor = lib.mkDefault "normal"; powerManagement.cpuFreqGovernor = lib.mkDefault "normal";
services.power-profiles-daemon.enable = false; services.power-profiles-daemon.enable = false;
services.upower.enable = true; services.upower.enable = true;
boot.extraModulePackages = perf_policy; #boot.extraModulePackages = [
# cpupower
#] ++ optional enable_perf_policy x86_energy_perf_policy;
services.tlp = { services.tlp = {
enable = true; enable = true;

View File

@ -13,7 +13,6 @@ in
config = with cfg; lib.mkIf (enable && tooling.enable) { config = with cfg; lib.mkIf (enable && tooling.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@") (writeShellScriptBin "systemd-owner" "systemctl show -pUser,UID $@")
(writeShellScriptBin "lsiommu" ./lsiommu)
(writeShellScriptBin "tree" "${lib.getExe pkgs.eza} -T --git -lh --no-permissions --no-user --no-filesize --no-time") (writeShellScriptBin "tree" "${lib.getExe pkgs.eza} -T --git -lh --no-permissions --no-user --no-filesize --no-time")
urlencode urlencode
pstree pstree
@ -30,7 +29,7 @@ in
fbcat fbcat
gomuks gomuks
gotop btop
ranger ranger
wget wget
file file

View File

@ -17,12 +17,12 @@ in
]; ];
wlr.enable = true; wlr.enable = true;
wlr.settings = lib.mapAttrs' wlr.settings = with lib; mapAttrs'
(name: value: lib.nameValuePair ("screencast_" + name) { (name: value: nameValuePair ("screencast_" + name) {
output_name = value.id; output_name = value.id;
max_fps = value.fps; max_fps = if isInt value.fps then value.fps else (foldl' min 2147483647 value.fps);
chooser_type = "simple"; chooser_type = "simple";
chooser_cmd = "${lib.getExe pkgs.slurp} -f %o -or"; chooser_cmd = "${getExe pkgs.slurp} -f %o -or";
}) })
cfg.screens; cfg.screens;
}; };

View File

@ -78,11 +78,11 @@
"yafas": "yafas" "yafas": "yafas"
}, },
"locked": { "locked": {
"lastModified": 1714482312, "lastModified": 1714566321,
"narHash": "sha256-qs41DgEGR2d6Hh+FnfL/6NagoCtRXDXC7yaGD398EXE=", "narHash": "sha256-cTWwPbwYtE8r6MuR+0ybG4CFeE8Sid5XHbFJq4itO+A=",
"owner": "chaotic-cx", "owner": "chaotic-cx",
"repo": "nyx", "repo": "nyx",
"rev": "8cfa2aa1528faa6319e2e5ab664ff463ba57708c", "rev": "5939d3fb76b25a48a8c0db716ebb6fe28eab3719",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -186,7 +186,7 @@
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
"url": "https://flakehub.com/f/ipetkov/crane/%2A.tar.gz" "url": "https://flakehub.com/f/ipetkov/crane/%3D0.16.1.tar.gz"
} }
}, },
"darwin": { "darwin": {
@ -220,12 +220,12 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1711952616, "lastModified": 1714544767,
"narHash": "sha256-WJvDdOph001fA1Ap3AyaQtz/afJAe7meSG5uJAdSE+A=", "narHash": "sha256-kF1bX+YFMedf1g0PAJYwGUkzh22JmULtj8Rm4IXAQKs=",
"rev": "209048d7c545905c470f6f8c05c5061f391031a8", "rev": "73124e1356bde9411b163d636b39fe4804b7ca45",
"revCount": 1822, "revCount": 1852,
"type": "tarball", "type": "tarball",
"url": "https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.1822%2Brev-209048d7c545905c470f6f8c05c5061f391031a8/018e98ba-d842-7dad-9d6a-0d0ee173b6b1/source.tar.gz" "url": "https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.1852%2Brev-73124e1356bde9411b163d636b39fe4804b7ca45/018f333a-c195-795f-9e07-b43b47d5391f/source.tar.gz"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
@ -382,11 +382,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1714430505, "lastModified": 1714515075,
"narHash": "sha256-SSJQ/KOy8uISnoZgqDoRha7g7PFLSFP/BtMWm0wUz8Q=", "narHash": "sha256-azMK7aWH0eUc3IqU4Fg5rwZdB9WZBvimOGG3piqvtsY=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "f8e6694edabe4aaa7a85aac47b43ea5d978b116d", "rev": "6d3b6dc9222c12b951169becdf4b0592ee9576ef",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -430,11 +430,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1714411325, "lastModified": 1714532637,
"narHash": "sha256-td58oD5JOlL8LPglrk+c7rP+nJSJmK7zu0kFGF16XPI=", "narHash": "sha256-2oWMEjkJKYzxLXy3OZ/M41VdbZgZLWmwttry551lUE4=",
"owner": "martinvonz", "owner": "martinvonz",
"repo": "jj", "repo": "jj",
"rev": "e54e83b0f5c4a5b7d80894c713ae402a5bb280d0", "rev": "7093d5d359fb3649be0d12a975f26d5607ad8f61",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -467,11 +467,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1714468768, "lastModified": 1714551038,
"narHash": "sha256-lxbNfjtTOcY18E9ODj3ZwJiF8UWr58CH+/9V3eHdtoQ=", "narHash": "sha256-/b4HT/RYfNkKUUpIzIwsHThLLAuKA70O8W/32sh2N0M=",
"owner": "YaLTeR", "owner": "YaLTeR",
"repo": "niri", "repo": "niri",
"rev": "68ff36f6834beecf74b30a724ae3ef31874a3518", "rev": "af9caa1d9b176fe3606323a8c05c0c741c1f6c0a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -657,11 +657,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1711885694, "lastModified": 1714501997,
"narHash": "sha256-dyezzeSbWMpflma+E9USmvSxuLgGcNGcGw3cOnX36ko=", "narHash": "sha256-g31zfxwUFzkPgX0Q8sZLcrqGmOxwjEZ/iqJjNx4fEGo=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "e4a405f877efd820bef9c0e77a02494e47c17512", "rev": "49e502b277a8126a9ad10c802d1aaa3ef1a280ef",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -42,6 +42,10 @@
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/307541.patch"; url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/307541.patch";
hash = "sha256-cyxiWCxBOKrET710C8o9Cwksy64HRez6mB1qF+anHMI="; hash = "sha256-cyxiWCxBOKrET710C8o9Cwksy64HRez6mB1qF+anHMI=";
} }
{
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/308476.patch";
hash = "sha256-J/Bvz4RUn9lP7H4s/c6bZEX9dfWsxfG/dpXYF99U3Vs=";
}
]; ];
customNixosSystem = system: definitions: customNixosSystem = system: definitions:

View File

@ -36,12 +36,12 @@
screens = { screens = {
external = { external = {
id = "HDMI-A-1"; id = "HDMI-A-1";
pos = "0,0"; pos = "0 0";
}; };
internal = { internal = {
id = "eDP-1"; id = "eDP-1";
fps = 144; fps = [ 144 60 ];
}; };
}; };
laptop_hardware.enable = true; laptop_hardware.enable = true;

View File

@ -18,6 +18,7 @@ in
qt6ct qt6ct
swaynotificationcenter swaynotificationcenter
searchclip searchclip
ydotool
]; ];
grimmShared.sway = { grimmShared.sway = {
@ -166,9 +167,8 @@ in
XF86Mail = let open = pkgs.writeShellScriptBin "open_or_switch_mail" '' XF86Mail = let open = pkgs.writeShellScriptBin "open_or_switch_mail" ''
desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//") desk=$(xdg-settings get default-url-scheme-handler mailto | sed "s/\.desktop//")
swaymsg [app_id="$desk"] focus || deskwhich $desk | xargs gio launch swaymsg [app_id="$desk"] focus || deskwhich $desk | xargs gio launch
''; ''; in "exec ${getExe open}";
in "exec ${getExe open}"; # XF86Bluetooth = "exec blueman-manager";
}; };
autolaunch = with pkgs; [ autolaunch = with pkgs; [
# fixme: absolute paths # fixme: absolute paths