101 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{ system, inputs, impurity, lib, config, pkgs, ... }: let
 | 
						|
  inherit (inputs) hyprland hyprland-hy3 quickshell;
 | 
						|
 | 
						|
  exe = hyprland.packages.${system}.default.overrideAttrs (final: prev: {
 | 
						|
    dontStrip = true;
 | 
						|
  });
 | 
						|
 | 
						|
  # I blame home manager
 | 
						|
  wrapper = pkgs.callPackage ({ ... }: pkgs.writeShellScriptBin "hyprland" ''
 | 
						|
    ${builtins.readFile ./session.sh}
 | 
						|
    ${config.hyprland-session.prerun}
 | 
						|
    ${lib.getExe exe} $@
 | 
						|
  '') {};
 | 
						|
in {
 | 
						|
  imports = [ hyprland.nixosModules.default ];
 | 
						|
 | 
						|
  options.hyprland-session = with lib; {
 | 
						|
    prerun = mkOption {
 | 
						|
      type = types.separatedString "\n";
 | 
						|
      default = "";
 | 
						|
    };
 | 
						|
 | 
						|
    extraConfig = mkOption {
 | 
						|
      type = types.separatedString "\n";
 | 
						|
      default = "";
 | 
						|
    };
 | 
						|
 | 
						|
    # same as above but no impurity so the greeter works
 | 
						|
    extraConfigStatic = mkOption {
 | 
						|
      type = types.separatedString "\n";
 | 
						|
      default = "";
 | 
						|
    };
 | 
						|
  };
 | 
						|
 | 
						|
  config = {
 | 
						|
    programs.hyprland.enable = true;
 | 
						|
 | 
						|
    nix.settings = {
 | 
						|
      substituters = [ "https://hyprland.cachix.org" ];
 | 
						|
      trusted-public-keys = [ "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ];
 | 
						|
    };
 | 
						|
 | 
						|
    home-manager.users.${config.main-user} = {
 | 
						|
      imports = [ hyprland.homeManagerModules.default ];
 | 
						|
 | 
						|
      home.packages = with pkgs; [
 | 
						|
        wrapper
 | 
						|
 | 
						|
        # environment programs
 | 
						|
        wl-clipboard
 | 
						|
        grim
 | 
						|
        slurp
 | 
						|
        playerctl
 | 
						|
        wl-screenrec
 | 
						|
 | 
						|
        hyprsunset
 | 
						|
        hyprpicker
 | 
						|
      ];
 | 
						|
 | 
						|
      wayland.windowManager.hyprland = {
 | 
						|
        enable = true;
 | 
						|
 | 
						|
        package = wrapper;
 | 
						|
        plugins = [ hyprland-hy3.packages.${system}.default ];
 | 
						|
 | 
						|
        extraConfig = ''
 | 
						|
          source = ${impurity.link ./hyprland.conf}
 | 
						|
          ${config.hyprland-session.extraConfig}
 | 
						|
        '';
 | 
						|
      };
 | 
						|
 | 
						|
 | 
						|
      # MUST be specified under home manager or home manager will silently replace
 | 
						|
      # configs at the system level.
 | 
						|
      xdg.portal = {
 | 
						|
        enable = true;
 | 
						|
 | 
						|
        extraPortals = lib.mkForce (with pkgs; [
 | 
						|
          xdg-desktop-portal-hyprland
 | 
						|
          kdePackages.xdg-desktop-portal-kde
 | 
						|
        ]);
 | 
						|
 | 
						|
        configPackages = lib.mkForce [];
 | 
						|
        config.common = {
 | 
						|
          default = [ "hyprland" ];
 | 
						|
          "org.freedesktop.impl.portal.FileChooser" = [ "kde" ];
 | 
						|
        };
 | 
						|
      };
 | 
						|
 | 
						|
      # Without this the portal blocks on desktop portals not being ready...
 | 
						|
      systemd.user.services.plasma-xdg-desktop-portal-kde.Service = {
 | 
						|
        ExecStart = "${pkgs.kdePackages.xdg-desktop-portal-kde}/libexec/xdg-desktop-portal-kde";
 | 
						|
        BusName = "org.freedesktop.impl.portal.desktop.kde";
 | 
						|
        Restart = "no";
 | 
						|
        Environment = [
 | 
						|
          "QT_QPA_PLATFORMTHEME="
 | 
						|
        ];
 | 
						|
      };
 | 
						|
    };
 | 
						|
  };
 | 
						|
}
 |