create .desktop file, pass parameters to hl2_launcher

This commit is contained in:
user 2024-12-26 02:22:04 +03:00
parent 6850933db7
commit ad1491d944
3 changed files with 38 additions and 4 deletions

View File

@ -1,16 +1,46 @@
{ callPackage
, symlinkJoin
, fetchurl
, makeDesktopItem
, copyDesktopItems
, hl2-unwrapped ? callPackage ./hl2-unwrapped.nix { }
, hl2-wrapper ? callPackage ./hl2-wrapper.nix { inherit hl2-unwrapped; }
}:
symlinkJoin {
let
name = "hl2";
icon = fetchurl {
url = "https://upload.wikimedia.org/wikipedia/commons/1/14/Half-Life_2_Logo.svg";
hash = "sha256-/4GlYVAUSZiK7eLjM/HymcGphk5s2uCPOQuB1XOstuI=";
};
in
symlinkJoin rec{
inherit name;
paths = [
hl2-unwrapped
hl2-wrapper
] ++ desktopItems;
nativeBuildInputs = [
copyDesktopItems
];
postBuild = "ln -s $out/bin/hl2-wrapper $out/bin/hl2";
postBuild = ''
ln -s $out/bin/hl2-wrapper $out/bin/${name}
install -Dm444 ${icon} $out/share/icons/hicolor/scalable/apps/${name}.svg
'';
desktopItems = [
(makeDesktopItem {
name = "${name}";
exec = "${name}";
icon = "${name}";
desktopName = "Half-Life 2";
comment = "Built from the leaked source code";
categories = [ "Game" ];
})
];
}

View File

@ -43,6 +43,6 @@ stdenv.mkDerivation {
wafConfigureFlags = [
"-T fastnative"
"--disable-warns"
"--build-flags=-Wno-error=format-security,-O3"
"--build-flags=-Wno-error=format-security"
] ++ extraWafConfigureFlags;
}

View File

@ -53,6 +53,10 @@ writeShellScriptBin "hl2-wrapper" ''
resource_path="$2"
shift 2
;;
-p | --parameters) # Sets parameters passed to hl2 launcher (encapsulated with quotes)
launcher_parameters="$2"
shift 2
;;
--impermanent) # Don't save newly created files that are not in symlimked folders (you probably don't want to use this)
impermanent=true
shift 1
@ -101,5 +105,5 @@ writeShellScriptBin "hl2-wrapper" ''
trap cleanup EXIT
( cd $tmp_dir ; ./hl2_launcher )
( cd $tmp_dir ; ./hl2_launcher $launcher_parameters )
''