aboutsummaryrefslogtreecommitdiffstats
path: root/modules/gaming/heroic/default.nix
blob: 61eceb52175a9a93bb3db78ac13745701c6bd6ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Epic, GOG and Amazon game launcher
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.gaming.heroic;
in
{
  options.gaming.heroic = {
    enable = lib.mkEnableOption "Enables Heroic Games Launcher.";
    package = lib.mkOption {
      type = lib.types.package;
      default = pkgs.symlinkJoin {
        name = "heroic-wrapped";
        paths = [
          pkgs.winetricks
          pkgs.xdg-user-dirs
          pkgs.gamemode
          pkgs.heroic
        ];
        buildInputs = [ pkgs.makeWrapper ];
        postBuild = ''
          wrapProgram $out/bin/heroic \
            --prefix LD_LIBRARY_PATH : "${pkgs.gamemode.lib}/lib:${pkgs.pkgsi686Linux.gamemode.lib}/lib"
        '';
      };
      description = "Heroic Games Launcher package (wrapped with GameMode support).";
    };
  };

  config = lib.mkIf cfg.enable {
    home.packages = [ cfg.package ];

    home.file.".local/share/icons/hicolor/scalable/apps/com.heroicgameslauncher.hgl.svg".source =
      config.lib.file.mkOutOfStoreSymlink "${pkgs.heroic}/share/icons/hicolor/scalable/apps/com.heroicgameslauncher.hgl.svg";

    xdg.desktopEntries."heroic" = {
      name = "Heroic Games Launcher";
      exec = "${lib.getExe' cfg.package "heroic"} %u";
      icon = "com.heroicgameslauncher.hgl";
      comment = "An Open Source Launcher for GOG, Epic Games and Amazon Games";
      categories = [ "Game" ];
      mimeType = [ "x-scheme-handler/heroic" ];
      type = "Application";
    };

    xdg.mimeApps.defaultApplications = {
      "x-scheme-handler/heroic" = "heroic.desktop";
    };
  };
}