• Operand
  • # (b)ring mi - belles.

gram:build

> ./nixos/module/hypr.nix

Lenses
(coming soon!)


{ home-manager, lib, hyprland, ... } @ inputs: let
  pkgs = inputs.nixpkgs.outputs.legacyPackages.x86_64-linux;
  nushell = pkgs.nushell;
in {
  # 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; }
  ];

  # hardware.opengl.extraPackages = with pkgs; [ intel-media-driver intel-vaapi-driver ];
  # # hyprland on nvidia graphics
  environment.sessionVariables = {
    WLR_NO_HARDWARE_CURSORS = "1";
    NIXOS_OZONE_WL = "1";
  };

  hardware = {
    opengl.enable = true;
    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 = {
    imports = [
      { home.file.".local/share/icons/future-cyan".source = "${fetchGit {
          url = "https://gitlab.com/Pummelfisch/future-cyan-hyprcursor";
          rev = "60fc69d603a6d7b99c1841a2c4cebd130b1aa357";
        }}/Future-Cyan-Hyprcursor_Theme";
        wayland.windowManager.hyprland.settings.exec-once = ["hyprctl setcursor Future-Cyan 48"];
      }
    ];

    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 hyprpaper hyprpicker pyprland
      alacritty zellij fuzzel meli libnotify mako pavucontrol # hybridbar
      waybar wl-clipboard cinnamon.nemo networkmanagerapplet wlsunset
    ];


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

    wayland.windowManager.hyprland = let
      console = command: "${pkgs.alacritty}/bin/alacritty -e nu -e '${command}'";
      nu = command: "${nushell}/bin/nu -l -c '${command}'";
    in {
      enable = true;
      xwayland.enable = true;
      systemd.enable = true;
      systemd.variables = ["--all"];
      package = pkgs.hyprland;
      # plugins = [ inputs.hyprfocus.packages.${pkgs.system}.hyprfocus ];
      # plugins = [ inputs.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 = [
          "hypridle" "pypr" "nm-applet --indicator" "hyprpaper"
          "waybar -c ~/.config/waybar/config -s ~/.config/waybar/theme.css"
          # "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP"
        ];

          # "$c $a, C, exec, ${nushell}/bin/nu -c 'nix-shell -p ffmpeg gphoto2 --command \"gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video0 -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video1\"'"
          # "$c $a, Z, exec, ${nushell}/bin/nu -c 'nu -c 'ns mpv $\"av://v4l2:/dev/video1 --profile=low-latency --untimed\"'"
          # "$c $a, X, exec, ${nushell}/bin/nu -c 'ns ffmpeg $\"-f v4l2 -framerate 30 -i /dev/video0 ($env.HOME)/rec/camera.(nix-shell -p dateutils --command \\'date -Is\\').mkv\"'"
          # def screen-rec [] { ns wf-recorder $"--audio='USB Composite Device Pro'" }

        bind = [
          "$c, R, exec, $menu"
          "$c, SPACE, exec, fuzzel"
          "$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 "session hop"}"
          "$c, I, exec, ${console "session hop issue"}"
          "$c $a, Q, exec, ${console "session hop"}"
          "$c $a, Q, exec, ${console "session record"}"

          "$c $b, M, exec, ${console "muse"}" # music
          "$c $a, E, exec, ${console "meli"}" # email

          # audio mixing
          # "$c, A, exec, pavucontrol"
          "$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, 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"
          "$c, 0, workspace, 10"

          # Move active window to a workspace with c + $a + [0-9]
          "$c $a, 1, movetoworkspace, 1"
          "$c $a, 2, movetoworkspace, 2"
          "$c $a, 3, movetoworkspace, 3"
          "$c $a, 4, movetoworkspace, 4"
          "$c $a, 5, movetoworkspace, 5"
          "$c $a, 6, movetoworkspace, 6"
          "$c $a, 7, movetoworkspace, 7"
          "$c $a, 8, movetoworkspace, 8"
          "$c $a, 9, movetoworkspace, 9"
          "$c $a, 0, movetoworkspace, 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 term && hyprctl dispatch bringactivetotop"
          "$c,A,exec,pypr toggle pavucontrol && 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,1,exec,${nu "screen shine 1"}"
          "$b $d,2,exec,${nu "screen shine 2"}"
          "$b $d,3,exec,${nu "screen shine 3"}"
          "$b $d,4,exec,${nu "screen shine 4"}"
          "$b $d,5,exec,${nu "screen shine 5"}"
          "$b $d,6,exec,${nu "screen shine 6"}"
          "$b $d,0,exec,${nu "screen shine 0"}"
          "$b $d, comma, exec, ${nu "screen shine 0"}"
          # "$c $a, comma, exec, nix-shell -p light --command 'light -S 1'"

          # ", 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 ..."

          # 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%"

        ];

        # See https://wiki.hyprland.org/Configuring/Monitors/
        monitor = [
          # chassis screen
          "desc:BOE 0x095F, preferred, 0x0 ,1.175" # origin

          # lab-bigscreen
          # "desc:Technical Concepts Ltd 43S455,highres, -4096x0, 1" #left
          "desc:Technical Concepts Ltd 43S455,highres, 0x-1620, 1.333333" # up

          # mobile-plugscreen
          # "desc:ASUSTek COMPUTER INC ASUS MB16AMT N2LMTF111011,highrr, -${
          #  toString (builtins.floor (4096 + (1920 / 1.2)))
          #}x0, 1.2"
          # "desc:ASUSTek COMPUTER INC ASUS MB16AMT N2LMTF111011,highrr, auto, 1.2"

          ",preferred,auto,1"
        ];
      };

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

  env = LIBVA_DRIVER_NAME,nvidia
  env = XDG_SESSION_TYPE,wayland
  env = GBM_BACKEND,nvidia-drm
  env = __GLX_VENDOR_LIBRARY_NAME,nvidia
  env = XCURSOR_SIZE,48
  env = WLR_DRM_DEVICES,/dev/dri/card0

  cursor {
    # no_hardware_cursors = true
  }

  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:ralt
    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 = 4
      gaps_out = 4
      border_size = 2
      col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
      col.inactive_border = rgba(595959aa)

      layout = dwindle

      # 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 = 10
      drop_shadow = yes
      shadow_range = 4
      shadow_render_power = 3
      col.shadow = rgba(1a1a1aee)
  }

  animations {
      enabled = yes
      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
  }

  #     # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more

  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
  # }

  # Example windowrule v1
  # windowrule = float, ^(alacritty)$
  # Example windowrule v2
  # windowrulev2 = float,class:^(alacritty)$,title:^(alacritty)$
  # 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

  $pavucontrol = class:^(pavucontrol)$
  windowrulev2 = float,$pavucontrol
  windowrulev2 = size 86% 40%,$pavucontrol
  windowrulev2 = move 50% 6%,$pavucontrol
  windowrulev2 = workspace special silent,$pavucontrol
  windowrulev2 = opacity 0.80,$pavucontrol

  # Resize using keyboard arrows.
  bind=ALT,R,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
  bind=,escape,submap,reset
  submap=reset

      '';
    };
  };
}