• Operand
  • da ploy? ed.

gram: build

> ./nixos/module/hypr.nix

Lenses
(coming soon!)


{ lib, pkgs, edge, ... } @ sources: {
  # programs.hyprland.enable = true;
  systemd.tmpfiles.rules = [ "d /run/user/1000/hypr 1777 root wheel 42d" ];

  # https://github.com/flatpak/xdg-desktop-portal/blob/1.18.1/doc/portals.conf.rst.in
  xdg.portal.config.common.default = "*";

  users.users.calliope.extraGroups = [ "video" ];
  programs.light.enable = true;
  security.pam.loginLimits = [
    { domain = "@users"; item = "rtprio"; type = "-"; value = 1; }
  ];

  # # hyprland on nvidia graphics
  environment.sessionVariables = {
    WLR_NO_HARDWARE_CURSORS = "1";
    NIXOS_OZONE_WL = "1";
    # LIBVA_DRIVER_NAME = "nvidia";
    XDG_SESSION_TYPE = "wayland";
    # GBM_BACKEND = "nvidia-drm";
    # __GLX_VENDOR_LIBRARY_NAME = "nvidia";
    XCURSOR_SIZE = "48";
    # WLR_DRM_DEVICES = "/dev/dri/card0";
    QT_QPA_PLATFORM="wayland;xcb";
  };

  hardware = {
    graphics.enable = true;
  # opengl.extraPackages = with pkgs; [ intel-media-driver intel-vaapi-driver ];
    # nvidia.modesetting.enable = true;
  };

  xdg.portal = { enable = true; wlr.enable = true; extraPortals = with pkgs; [
    xdg-desktop-portal-gtk
    xdg-desktop-portal-hyprland
  ]; };

  home-manager.users.calliope = {
    programs.hyprpanel = {
      enable = true;
      overlay.enable = true;
      overwrite.enable = true;
      hyprland.enable = true;
      theme = "one_dark";
      settings = {
        wallpaper.enable = false;
        theme.bar.transparent = true;
        theme.bar.opacity = 0;
        menus.power.lowBatteryNotification = true;
        menus.power.lowBatteryNotificationText = "Charge is $POWER_LEVEL %.\\n\\nPlease plug in a charger.";
        menus.power.lowBatteryNotificationTitle = "Recharge!";
        menus.power.lowBatteryThreshold = 20;
    }; };

    imports = [
      sources.hyprpanel.homeManagerModules.hyprpanel
      { home.file.".local/share/icons/future-cyan".source = "${fetchGit {
          url = "https://gitlab.com/Pummelfisch/future-cyan-hyprcursor.git";
          rev = "60fc69d603a6d7b99c1841a2c4cebd130b1aa357";
        }}/Future-Cyan-Hyprcursor_Theme";
      }
    ];

    home.packages = with pkgs; let
      hybridbar = rustPlatform.buildRustPackage rec {
        pname = "HybridBar"; version = "0.4.9";
        src = fetchFromGitHub { owner = "vars1ty"; repo = pname; rev = version;
          sha256 = "e9QVDDN8AtCZYuYqef1rzLJ0mklaKXzxgj+ZqGrSYEY="; };
        cargoSha256 = "50Go2AJQqgG2chc70KqKJexffD1rpObXr85ZPAIqc/U=";

        meta = with lib; {
          description = "A status bar focused on wlroots Wayland compositors";
          homepage = "https://github.com/vars1ty/HybridBar";
          license = licenses.mit; maintainers = [];
        };
      };
    in [
      hypridle hyprlock hyprpicker hyprpanel hyprpaper
      alacritty kitty pyprland zellij fuzzel libnotify font-awesome
      wl-clipboard nemo networkmanagerapplet wlsunset
    ];


# font_family = ''+userSettings.font+''

    wayland.windowManager.hyprland = let
      console = command: "${pkgs.alacritty}/bin/alacritty -e ${edge.nushell}/bin/nu -e '${command}'";
      nu = command: "${edge.nushell}/bin/nu -l -c '${command}'";
    in {
      enable = true;
      xwayland.enable = true;
      systemd.enable = true;
      systemd.variables = ["--all"];
      package = pkgs.hyprland;
      # plugins = [ sources.hyprfocus.packages.${pkgs.system}.hyprfocus ];
      # plugins = [ sources.hyprland-plugins.packages.${pkgs.system}.hyprtrails ];


      settings = {
        "$fileManager" = "nemo";
        "$menu" = "fuzzel";

        # see https://wiki.hyprland.org/Configuring/Binds
        # SHIFT # CAPS # CTRL/CONTROL # ALT # MOD2 # MOD3 # SUPER/WIN/LOGO/MOD4 # MOD5
        "$a" = "SHIFT";
        "$b" = "CTRL";
        "$c" = "SUPER";
        "$d" = "ALT";

        # exec = [ "nix-shell -p ntp --command ntpdate time.nist.gov" ];

        exec-once = [
          # (console "session record (sessions | get 0)")
          "hyprctl setcursor Future-Cyan 48"
          "hypridle" "pypr" "hyprpaper"
          "${pkgs.hyprpanel}/bin/hyprpanel"
          # "nm-applet --indicator"
          # "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
          # "kitty +kitten panel --edge=background zellij -s log -l log"
        ];

        bind = [
          "$c, SPACE, exec, $menu"
          "$c, F, exec, firefox"
          "$c, E, exec, $fileManager"
          "$c, slash, exec, hyprlock"
          "$c $b, slash, exec, ${nu ''ps | where name =~ 'Hyprland' | get pid | each {|p| kill $p }''}"

          # console sessions
          "$c, Q, exec, ${console "hop"}"
          "$c, R, exec, ${console "hop read"}"
          "$c $b, M, exec, ${console "hop muse"}"
          # "$c, I, exec, ${console "session hop issue"}"
          # "$c $a, E, exec, ${console "meli"}" # email

          # audio mixing
          "$c $a, A, exec, qjackctl"
          "$c, B, exec, blueman-manager"

          # end processes
          "$c, C, killactive, "
          "$c, escape, exit, "

          # connections
          "$c, X, exec, alacritty -e nmtui"
          "$c $a, X, exec, nm-connection-editor"

          # maximize
          "$c, M, exec, hyprctl dispatch fullscreen 1"
          "$c $a, M, exec, hyprctl dispatch fullscreen 0"

          # resize and arrange
          "$c, V, togglefloating, "
          "$c, P, pseudo, "
          "$c, O, togglesplit, "

          # Move focus with c + arrow keys
          "$c, left, movefocus, l"
          "$c, right, movefocus, r"
          "$c, up, movefocus, u"
          "$c, down, movefocus, d"

          "$c, H, movefocus, l"
          "$c, L, movefocus, r"
          "$c, K, movefocus, u"
          "$c, J, movefocus, d"

          "$c $a, H, swapwindow, l"
          "$c $a, L, swapwindow, r"
          "$c $a, K, swapwindow, u"
          "$c $a, J, swapwindow, d"

          # Switch workspaces with c + [0-9]
          "$c, 0, workspace, 0"
          "$c, 1, workspace, 1"
          "$c, 2, workspace, 2"
          "$c, 3, workspace, 3"
          "$c, 4, workspace, 4"
          "$c, 5, workspace, 5"
          "$c, 6, workspace, 6"
          "$c, 7, workspace, 7"
          "$c, 8, workspace, 8"
          "$c, 9, workspace, 9"

          # Move active window to a workspace with c + $a + [0-9]
          "$c $a, 1, movetoworkspacesilent, 1"
          "$c $a, 2, movetoworkspacesilent, 2"
          "$c $a, 3, movetoworkspacesilent, 3"
          "$c $a, 4, movetoworkspacesilent, 4"
          "$c $a, 5, movetoworkspacesilent, 5"
          "$c $a, 6, movetoworkspacesilent, 6"
          "$c $a, 7, movetoworkspacesilent, 7"
          "$c $a, 8, movetoworkspacesilent, 8"
          "$c $a, 9, movetoworkspacesilent, 9"
          "$c $a, 0, movetoworkspacesilent, 10"

          # Example special workspace (scratchpad)
          "$c, S, togglespecialworkspace, magic"
          "$c $a, S, movetoworkspace, special:magic"
          "$c $a, S, togglespecialworkspace, magic"

          # Scroll through existing workspaces with c + scroll
          "$c, mouse_down, workspace, e+1"
          "$c, mouse_up, workspace, e-1"

          # Quick accions using pypr
          "$c,tab,exec,pypr toggle console && hyprctl dispatch bringactivetotop"
          # "$c,F,exec,pypr toggle ranger && hyprctl dispatch bringactivetotop"
          # "$c,N,exec,pypr toggle musikcube && hyprctl dispatch bringactivetotop"
          # "$c,B,exec,pypr toggle btm && hyprctl dispatch bringactivetotop"
          # "$c,E,exec,pypr toggle geary && hyprctl dispatch bringactivetotop"
        ];

        bindm = [
          # Move/resize windows with c + LMB/RMB and dragging
          "$c, mouse:272, movewindow"
          "$c, mouse:273, resizewindow"
        ];

        # Media and audio keys!
        bindel = [
          # screen shine
          "$b $d, comma, exec, light -S 0"
          "$b $d,1,exec,light -S 10"
          "$b $d,2,exec,light -S 20"
          "$b $d,3,exec,light -S 30"
          "$b $d,4,exec,light -S 40"
          "$b $d,5,exec,light -S 50"
          "$b $d,6,exec,light -S 60"
          "$b $d,7,exec,light -S 70"
          "$b $d,8,exec,light -S 80"
          "$b $d,9,exec,light -S 90"
          "$b $d,0,exec,light -S 100"

          # ", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"

          # ",XF86MonBrightnessUp,exec,nix-shell -p light --command light -S 1"
          # ",XF86MonBrightnessDown,exec,nix-shell -p light --command light -S 0"
          # ",XF86AudioNext,exec,wpctl set-volume ..."
          # ",XF86AudioPlay,exec,wpctl set-volume ..."
          # ",XF86AudioPrev,exec,wpctl set-volume ..."

          # keyboard scroll
          "$b, XF86AudioRaiseVolume, exec, hyprctl dispatch sendshortcut ',Down,active'"
          "$b, XF86AudioLowerVolume, exec, hyprctl dispatch sendshortcut ',Up,active'"
          "SHIFT_R, XF86AudioRaiseVolume, exec, hyprctl dispatch sendshortcut ',Down,active'"
          "SHIFT_R, XF86AudioLowerVolume, exec, hyprctl dispatch sendshortcut ',Up,active'"

          # Usual media keys!
          ", XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%+"
          ", XF86AudioLowerVolume, exec, wpctl set-volume -l 1.4 @DEFAULT_AUDIO_SINK@ 5%-"
          ", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle "

          # Unusual media keys!
          ",Print,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" # less loud
          "$a,Print,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-" # less loud
          "$b,Print,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 0%"

          ",XF86AudioMedia,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+" # more loud
          "$a,XF86AudioMedia,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+" # more loud
          "$b,XF86AudioMedia,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 100%"

        ];
      };

      extraConfig = ''
  # See https://wiki.hyprland.org/Configuring/Keywords/ for more

  # env=WLR_DRM_DEVICES,/dev/dri/card0

  cursor {
    # no_hardware_cursors = true
  }

  master {
    mfact = 0.50
    new_on_top = true
    new_status = inherit
    orientation = left
  }

  misc {
    disable_hyprland_logo = true
    disable_splash_rendering = true
  }

  # For all categories, see https://wiki.hyprland.org/Configuring/Variables/
  input {
    touchpad {
      clickfinger_behavior = 1
    }

    kb_layout = us
    kb_variant =
    kb_model =
    kb_options = ctrl:nocaps, grp:alt_shift_toggle, compose:rctrl
    kb_rules =
    follow_mouse = 1

    touchpad {
      natural_scroll = no
    }

    sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
  }

  general {
      # See https://wiki.hyprland.org/Configuring/Variables/ for more
      gaps_in = 0
      gaps_out = 0
      border_size = 2
      col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
      col.inactive_border = rgba(595959aa)

      # layout = dwindle
      layout = master

      # Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
      allow_tearing = false
  }

  # decoration {
  #     # See https://wiki.hyprland.org/Configuring/Variables/ for more
  #     blur {
  #       enabled = true
  #       size = 3
  #       passes = 1
  #     }
  #     rounding = 0
  #     drop_shadow = yes
  #     shadow_range = 4
  #     shadow_render_power = 3
  #     col.shadow = rgba(1a1a1aee)
  # }

  animations {
      # enabled = yes
      enabled = no
      bezier = myBezier, 0.05, 0.9, 0.1, 1.05

      # Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
      animation = windows, 1, 7, myBezier
      animation = windowsOut, 1, 7, default, popin 80%
      animation = border, 1, 10, default
      animation = borderangle, 1, 8, default
      animation = fade, 1, 7, default
      animation = workspaces, 1, 6, default
  }

  dwindle {
      # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
      # pseudotile = yes
      preserve_split = yes # you probably want this
  }

  gestures {
      # See https://wiki.hyprland.org/Configuring/Variables/ for more
      workspace_swipe = off
  }

  # Example per-device config
  # See https://wiki.hyprland.org/Configuring/Keywords/#executing for more
  # device:epic-mouse-v1 {
  #     sensitivity = -0.5
  # }

  # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
  # windowrulev2 = nomaximizerequest, class:.* # You'll probably like this.

  $scratchpadsize = size 80% 85%
  $scratchpad = class:^(scratchpad)$
  windowrulev2 = float,$scratchpad
  windowrulev2 = $scratchpadsize,$scratchpad
  windowrulev2 = workspace special silent,$scratchpad
  windowrulev2 = center,$scratchpad
  windowrulev2 = opacity 0.80,$scratchpad

  # Resize using keyboard arrows.
  bind=,End,submap,resize
  submap=resize
  binde=,right,resizeactive,15 0
  binde=,left,resizeactive,-15 0
  binde=,up,resizeactive,0 -15
  binde=,down,resizeactive,0 15
  binde=$a,right,resizeactive,60 0
  binde=$a,left,resizeactive,-60 0
  binde=$a,up,resizeactive,0 -60
  binde=$a,down,resizeactive,0 60
  # keyboard scroll
  bind=,XF86AudioRaiseVolume, exec, hyprctl dispatch sendshortcut ',Down,active'
  bind=,XF86AudioLowerVolume, exec, hyprctl dispatch sendshortcut ',Up,active'
  bind=,escape,submap,reset
  bind=,End,submap,reset
  submap=reset

      '';
    };
  };
}