diff --git a/common/default.nix b/common/default.nix index a5961f1..a339f26 100644 --- a/common/default.nix +++ b/common/default.nix @@ -16,6 +16,6 @@ with lib; ./gaming.nix ./firefox.nix ./cloudsync.nix - ./laptop_hardware.nix + ./hardware ]; } diff --git a/common/graphics/qt.nix b/common/graphics/qt.nix index 98ffb8c..d8d07aa 100644 --- a/common/graphics/qt.nix +++ b/common/graphics/qt.nix @@ -16,6 +16,8 @@ in libsForQt5.qtgraphicaleffects catppuccin-kvantum kdePackages.audiocd-kio + kdePackages.kio-extras + kdePackages.kio xcb-util-cursor qt6ct kdePackages.dolphin diff --git a/common/hardware/default.nix b/common/hardware/default.nix new file mode 100644 index 0000000..807d6f5 --- /dev/null +++ b/common/hardware/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./laptop.nix + ./tlp.nix + ]; +} diff --git a/common/laptop_hardware.nix b/common/hardware/laptop.nix similarity index 70% rename from common/laptop_hardware.nix rename to common/hardware/laptop.nix index 15ff5e1..beb2b3a 100644 --- a/common/laptop_hardware.nix +++ b/common/hardware/laptop.nix @@ -5,25 +5,20 @@ in { config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { environment.systemPackages = with pkgs; [ - acpi lm_sensors lshw pciutils usbutils - powertop opentabletdriver ddcutil ] ++ lib.optionals graphical [ ddcui - tlpui ]; - # services.ddccontrol.enable = true; - powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power"; hardware.i2c.enable = true; services.libinput.enable = true; - powerManagement.cpuFreqGovernor = lib.mkDefault "normal"; hardware.opentabletdriver.enable = true; + services.udisks2.enable = true; services.udev.extraRules = '' SUBSYSTEM=="i2c-dev", ACTION=="add",\ @@ -87,36 +82,10 @@ in ]; # blacklistedKernelModules = [ "i2c_nvidia_gpu" ]; }; - - services.power-profiles-daemon.enable = false; - # powerManagement.powertop.enable = true; - - services.upower.enable = true; - - services.tlp = { - enable = true; - settings = { - USB_AUTOSUSPEND = 1; - USB_EXCLUDE_BTUSB = 1; - USB_EXCLUDE_PHONE = 1; - SOUND_POWER_SAVE_ON_AC = 0; - SOUND_POWER_SAVE_ON_BAT = 1; - SATA_LINKPWR_ON_AC = "max_performance"; - SATA_LINKPWR_ON_BAT = "min_power"; - MAX_LOST_WORK_SECS_ON_BAT = 15; - CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; - CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; - CPU_BOOST_ON_AC = 1; - CPU_BOOST_ON_BAT = 0; - RUNTIME_PM_ON_AC = "on"; - RUNTIME_PM_ON_BAT = "auto"; - }; - }; }; options.grimmShared.laptop_hardware = { enable = lib.mkEnableOption "grimm-laptop"; }; - } diff --git a/common/hardware/tlp.nix b/common/hardware/tlp.nix new file mode 100644 index 0000000..3523d91 --- /dev/null +++ b/common/hardware/tlp.nix @@ -0,0 +1,43 @@ +{ pkgs, config, lib, system, ... }: +let + cfg = config.grimmShared; + perf_policy = lib.optional (lib.systems.elaborate system).isx86 config.boot.kernelPackages.x86_energy_perf_policy; +in +{ + config = with cfg; lib.mkIf (enable && laptop_hardware.enable) { + environment.systemPackages = with pkgs; [ + acpi + powertop + ] ++ lib.optionals graphical [ + tlpui + ] ++ perf_policy; + + powerManagement.scsiLinkPolicy = lib.mkIf (!config.services.tlp.enable) "min_power"; + powerManagement.cpuFreqGovernor = lib.mkDefault "normal"; + + services.power-profiles-daemon.enable = false; + services.upower.enable = true; + boot.extraModulePackages = perf_policy; + + services.tlp = { + enable = true; + settings = { + USB_AUTOSUSPEND = 1; + USB_EXCLUDE_BTUSB = 1; + USB_EXCLUDE_PHONE = 1; + SOUND_POWER_SAVE_ON_AC = 0; + SOUND_POWER_SAVE_ON_BAT = 1; + SATA_LINKPWR_ON_AC = "max_performance"; + SATA_LINKPWR_ON_BAT = "min_power"; + MAX_LOST_WORK_SECS_ON_BAT = 15; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_BOOST_ON_AC = 1; + CPU_BOOST_ON_BAT = 0; + RUNTIME_PM_ON_AC = "on"; + RUNTIME_PM_ON_BAT = "auto"; + }; + }; + }; +} + diff --git a/common/tooling/default.nix b/common/tooling/default.nix index b96436d..dd7a8ab 100644 --- a/common/tooling/default.nix +++ b/common/tooling/default.nix @@ -15,13 +15,15 @@ in (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") + urlencode + pstree + dos2unix gcc jdk17 pkg-config unzip p7zip - dos2unix tea eza diff --git a/common/xdg/mime.nix b/common/xdg/mime.nix index 60075e2..a40000b 100644 --- a/common/xdg/mime.nix +++ b/common/xdg/mime.nix @@ -36,6 +36,8 @@ in { config = with cfg; lib.mkIf (enable && portals && graphical) { environment.systemPackages = with pkgs; [ + (callPackage ../../custom/deskwhich/package.nix {}) + zathura imhex libreoffice-qt diff --git a/configuration.nix b/configuration.nix index 54c36f3..6602aa5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -43,7 +43,7 @@ }; }; cloudSync = { - # enable = true; + enable = true; username = "Grimmauld"; server = "cloud.grimmauld.de"; passwordFile = config.age.secrets.nextcloud_pass.path; diff --git a/custom/deskwhich/package.nix b/custom/deskwhich/package.nix new file mode 100644 index 0000000..1b425af --- /dev/null +++ b/custom/deskwhich/package.nix @@ -0,0 +1,27 @@ +{ fetchFromGitea +, lib +, rustPlatform +}: +rustPlatform.buildRustPackage rec { + pname = "deskwhich"; + version = "unstable-2024-04-30"; + + src = fetchFromGitea { + domain = "codeberg.org"; + owner = "axtlos"; + repo = "deskwhich"; + rev = "cbe8a0cdf4bdbb26faecb028e79ad6c409376051"; + hash = "sha256-c0Q0oYIB/1eutV7tkqYXvDMw8A7YsT+5+CmmwbGvcNk="; + }; + + cargoHash = "sha256-fBC3UBf9oLswlR6Kgw3nSwjqAtn7VQGzvbUJaYnOid4="; + + meta = { + description = "tool to find the path of desktop entries"; + homepage = "https://codeberg.org/axtlos/deskwhich"; + license = lib.licenses.gpl3Only; + mainProgram = "deskwhich"; + maintainers = with lib.maintainers; [ grimmauld ]; + platforms = lib.platforms.linux; + }; +} diff --git a/flake.nix b/flake.nix index fd16f3c..a4959e5 100644 --- a/flake.nix +++ b/flake.nix @@ -63,7 +63,6 @@ nixosConfigurations = { grimmauld-nixos = customNixosSystem "x86_64-linux" { modules = [ - (import ./overlays) agenix.nixosModules.default chaotic.nixosModules.default nix-gaming.nixosModules.pipewireLowLatency diff --git a/overlays/default.nix b/overlays/default.nix deleted file mode 100644 index 4a2b231..0000000 --- a/overlays/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ lib, config, ... }: { - nixpkgs.overlays = map (f: (final: prev: (import f { inherit final prev lib config; }))) - [ - ./wlr_flicker.nix - ]; -} diff --git a/overlays/wlr_flicker.nix b/overlays/wlr_flicker.nix deleted file mode 100644 index 668e174..0000000 --- a/overlays/wlr_flicker.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ final, prev, ... }: { - wlroots = prev.wlroots.overrideAttrs (o: { - patches = (o.patches or [ ]) ++ [ - # ./patches/lessflicker.patch - # ./patches/screenshare.patch - ]; - }); -} diff --git a/sway/default.nix b/sway/default.nix index 4d08a1e..7a5410b 100644 --- a/sway/default.nix +++ b/sway/default.nix @@ -1,4 +1,12 @@ -{ inputs, system, pkgs, config, lib, ... }: { +{ inputs, system, pkgs, config, lib, ... }: +let + searchclip = pkgs.writeShellScriptBin "searchclip" '' + xdg-open https://www.google.com/search?q=$(wl-paste -p | urlencode) + browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//") + swaymsg [app_id="$browser" urgent="newest"] focus + ''; +in + { environment.systemPackages = with pkgs; [ alacritty rmenu @@ -9,6 +17,7 @@ swaymux qt6ct swaynotificationcenter + searchclip ]; grimmShared.sway = { @@ -20,7 +29,9 @@ style = ./bar/style.css; }; - config = with lib; { + config = with pkgs; let + inherit (lib) getExe; + in { definitions = { mod = "Mod4"; left = "h"; @@ -28,8 +39,8 @@ up = "k"; right = "l"; term = getExe pkgs.alacritty; - menu = "${getExe pkgs.rmenu} -r drun | xargs swaymsg exec --"; - menu_run = "${getExe pkgs.rmenu} -r run | xargs swaymsg exec --"; + menu = "${getExe rmenu} -r drun | xargs swaymsg exec --"; + menu_run = "${getExe rmenu} -r run | xargs swaymsg exec --"; primecol = "#8800FF"; accentcol = "#5700a0"; @@ -42,8 +53,8 @@ keybinds = { "$mod+d" = "exec $menu"; "$mod+Shift+d" = "exec $menu_run"; - "$mod+Shift+s" = ''exec ${getExe pkgs.grim} -g "$(${getExe pkgs.slurp} -d)" - | wl-copy''; - "$mod+Return" = "exec $term -e xonsh"; + "$mod+Shift+s" = ''exec ${getExe grim} -g "$(${getExe slurp} -d)" - | wl-copy''; + "$mod+Return" = "exec $term --command xonsh"; "$mod+Shift+Return" = "exec $term"; "$mod+Shift+q" = "kill"; "$mod+Shift+c" = "reload"; @@ -136,9 +147,22 @@ XF86AudioPlay = "exec playerctl play-pause"; XF86AudioNext = "exec playerctl next"; XF86AudioPrev = "exec playerctl previous"; - "$mod+c" = "exec ${getExe pkgs.swaymux}"; - XF86MonBrightnessUp = "exec ${getExe pkgs.brightnessctl} s 10+%"; - XF86MonBrightnessDown = "exec ${getExe pkgs.brightnessctl} s 10-%"; + "$mod+c" = "exec ${getExe swaymux}"; + XF86MonBrightnessUp = "exec ${getExe brightnessctl} s 10+%"; + XF86MonBrightnessDown = "exec ${getExe brightnessctl} s 10-%"; + XF86Explorer = "exec $term --command ${getExe ranger}"; + XF86Search = "exec ${getExe searchclip}"; + XF86HomePage = let open = pkgs.writeShellScriptBin "open_or_switch_browser" '' + browser=$(xdg-settings get default-web-browser | sed "s/\.desktop//") + swaymsg [app_id="$browser"] focus || deskwhich $browser | xargs gio launch + ''; in "exec ${getExe open}"; + XF86Tools = let open = pkgs.writeShellScriptBin "open_or_switch_spotify" '' + # FIXME: spotify is being weird + while IFS= read -r pid; do + swaymsg [pid=$pid] focus && exit 0 + done <<< $(pgrep spotify -u "$(whoami)") + deskwhich spotify | xargs gio launch + ''; in "exec ${getExe open}"; # for some reason tools = audio media on my keyboard?? }; autolaunch = with pkgs; [ # fixme: absolute paths @@ -146,7 +170,7 @@ "lxqt-policykit-agent" "otd-daemon" swaynotificationcenter - # (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart + # (pkgs.writeShellScriptBin "rmenu-cache-clear" "rm -r $HOME/.cache/rmenu") # invalidate rmenu cache on sway restart "dbus-update-activation-environment" ]; extraConfig = ''