diff --git a/build.nix b/build.nix index f9d2fcb8..6249ffe2 100644 --- a/build.nix +++ b/build.nix @@ -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" ]; + }) + ]; } diff --git a/hl2-unwrapped.nix b/hl2-unwrapped.nix index 1a2cfef6..7d0ef9b0 100644 --- a/hl2-unwrapped.nix +++ b/hl2-unwrapped.nix @@ -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; } diff --git a/hl2-wrapper.nix b/hl2-wrapper.nix index 1151bdd9..d92e9fec 100644 --- a/hl2-wrapper.nix +++ b/hl2-wrapper.nix @@ -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 ) ''