From 880fb831fbd6e0350f620d71531494be2f3e1603 Mon Sep 17 00:00:00 2001 From: 514fpv Date: Wed, 3 Jan 2024 15:29:21 +0800 Subject: [PATCH] feat(gui): add base sway configuration --- home/gui/home.nix | 30 +++++++++++++++++++++++++++ home/gui/nixos.nix | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 home/gui/home.nix create mode 100644 home/gui/nixos.nix diff --git a/home/gui/home.nix b/home/gui/home.nix new file mode 100644 index 00000000..ac2701f5 --- /dev/null +++ b/home/gui/home.nix @@ -0,0 +1,30 @@ +{ pkgs +, lib +, config +, ... }: with lib; let + terminal = toString pkgs.alacritty; +in mkIf config.passthrough.gui { + wayland.windowManager.sway = { + enable = true; + config = { + modifier = "Mod4"; + keybindings = let + modifier = config.wayland.windowManager.sway.config.modifier; + in mkOptionDefault { + XF86MonBrightnessUp = "light -A 5"; + XF86MonBrightnessDown = "light -U 5"; + + "Control+Alt+l" = "${pkgs.swaylock}/bin/swaylock -c 000000"; + "Print" = "exec ${pkgs.grim}/bin/grim - | ${pkgs.wl-clipboard}/bin/wl-copy"; + "${modifier}+Print" = "exec ${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy"; + "${modifier}+q" = "exec google-chrome-stable"; + }; + + menu = "wofi -show drun -modi drun"; + }; + }; + + programs.wofi.enable = true; + programs.wofi.settings.mode = "drun"; + programs.wofi.settings.allow_images = true; +} diff --git a/home/gui/nixos.nix b/home/gui/nixos.nix new file mode 100644 index 00000000..7116448c --- /dev/null +++ b/home/gui/nixos.nix @@ -0,0 +1,51 @@ +{ pkgs +, lib +, config +, ... }: with lib; let + cfg = config.home.sway; + gui = with config.faucet.gui; ( enable && session ); +in { + options.home = { + sway = {}; + }; + + config = { + users.homeModules = [ + # this module passes gui configuration to home-manager + { passthrough.gui = gui; } + # this module passes sway-specific config values + { passthrough.sway = cfg; } + ]; + + users.home.persist = mkIf gui { + directories = [ + ".config/google-chrome" + ]; + }; + users.adminGroups = mkIf gui [ "video" ]; + + services.xserver.displayManager.sessionPackages = + mkIf gui [ (pkgs.writeTextFile { + name = "sway-session"; + destination = "/share/wayland-sessions/sway.desktop"; + text = '' + [Desktop Entry] + Name=Sway + Comment=An i3-compatible Wayland compositor + Exec=sway --unsupported-gpu + Type=Application + ''; + } // { providedSessions = [ pkgs.sway.meta.mainProgram ]; }) ]; + + security = mkIf gui { + polkit.enable = true; + chromiumSuidSandbox.enable = true; + pam.services.swaylock = { }; + }; + fonts.enableDefaultPackages = mkIf gui true; + programs = mkIf gui { + dconf.enable = true; + light.enable = true; + }; + }; +}