Skip to content

Commit

Permalink
peacock: init
Browse files Browse the repository at this point in the history
  • Loading branch information
NyCodeGHG committed Sep 26, 2024
1 parent fc49967 commit 0003e9f
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
currentHostPlatform
];
}).config.system.build.tarball;
peacock = pkgs.callPackage ./pkgs/peacock/package.nix { };
};
};

Expand Down Expand Up @@ -136,6 +137,7 @@
yt-dlp = prev.yt-dlp.overrideAttrs (prev: {
patches = (prev.patches or []) ++ [ ./patches/yt-dlp-ZDF-fields.patch ];
});
peacock = prev.callPackage ./pkgs/peacock/package.nix { };
}
))
);
Expand Down
5 changes: 5 additions & 0 deletions hosts/marie-desktop/gaming.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{ pkgs, config, lib, ... }:
{
imports = [
../../modules/nixos/peacock.nix
];
services.peacock.enable = true;

environment.systemPackages = with pkgs; [
prismlauncher
heroic
Expand Down
26 changes: 26 additions & 0 deletions modules/nixos/peacock.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.peacock;
inherit (lib)
mkEnableOption
mkOption
mkPackageOption
types
mkIf;
in
{
options.services.peacock = {
enable = mkEnableOption "peacock HITMAN game server";
package = mkPackageOption pkgs "peacock" { };
port = mkOption {
default = 6969;
type = types.port;
};
};

config = mkIf cfg.enable {
environment.systemPackages = [
(cfg.package.override { inherit (cfg) port; })
];
};
}
150 changes: 150 additions & 0 deletions pkgs/peacock/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
lib,
fetchFromGitHub,
stdenvNoCC,
nodejs,
yarn-berry,
cacert,
makeWrapper,
protontricks,
copyDesktopItems,
makeDesktopItem,
fetchurl,
port ? 6969,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
pname = "peacock";
version = "7.4.1";

src = fetchFromGitHub {
owner = "thepeacockproject";
repo = "Peacock";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-uHVEPuzKdt/NhI7vNI679FE5XqCbORbxXZvnYOYpLkE=";
};

yarnOfflineCache = stdenvNoCC.mkDerivation {
name = "tilt-assets-deps";
inherit (finalAttrs) src;

nativeBuildInputs = [ yarn-berry ];

supportedArchitectures = builtins.toJSON {
os = [ "darwin" "linux" ];
cpu = [ "arm" "arm64" "ia32" "x64" ];
libc = [ "glibc" "musl" ];
};

NODE_EXTRA_CA_CERTS = "${cacert}/etc/ssl/certs/ca-bundle.crt";

configurePhase = ''
runHook preConfigure
export HOME="$NIX_BUILD_TOP"
export YARN_ENABLE_TELEMETRY=0
yarn config set enableGlobalCache false
yarn config set cacheFolder $out
yarn config set supportedArchitectures --json "$supportedArchitectures"
runHook postConfigure
'';

buildPhase = ''
runHook preBuild
mkdir -p $out
yarn install --immutable --mode skip-build
runHook postBuild
'';

dontInstall = true;

outputHashAlgo = "sha256";
outputHash = "sha256-BR6dydEA+UWJk9d65sgvHw4E+zMA6iLcY+d8WYtXn6Q=";
outputHashMode = "recursive";
};

nativeBuildInputs = [
yarn-berry
nodejs
makeWrapper
copyDesktopItems
];

desktopItems = [
(makeDesktopItem {
name = "Peacock";
exec = "peacock";
path = "~/.local/share/peacock";
desktopName = "Peacock";
categories = [ "Game" ];
terminal = true;
comment = "Replacement server for the HITMAN™ World of Assassination trilogy";
icon = fetchurl {
url = "https://github.com/thepeacockproject/peacockprojectorg/blob/e6cc1733b79e7b6a4b362b5928b5d982ae93989e/static/img/feather.png?raw=1";
hash = "sha256-cUSyaNPD9ruw1jgGoVwtMcMwB0eDCWDjr6w1enmMC1c=";
};
})
];

configurePhase = ''
runHook preConfigure
export HOME="$NIX_BUILD_TOP"
export YARN_ENABLE_TELEMETRY=0
yarn config set enableGlobalCache false
yarn config set cacheFolder $yarnOfflineCache
runHook postConfigure
'';

buildPhase = ''
runHook preBuild
yarn install --immutable --immutable-cache
yarn build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share/peacock}
cp -r \
chunk*.js \
LICENSE \
THIRDPARTYNOTICES.txt \
PeacockPatcher.exe \
$out/share/peacock/
mkdir $out/share/peacock/resources
cp resources/dynamic_resources_h{3,2,1}.rpkg $out/share/peacock/resources
cp -r resources/{challenges,mastery,contracts.prp} $out/share/peacock/resources
mkdir $out/share/peacock/webui
cp -r webui/dist $out/share/peacock/webui
makeWrapper ${lib.getExe nodejs} $out/bin/peacock \
--add-flags "$out/share/peacock/chunk0.js" \
--set PORT ${toString port}
makeWrapper ${lib.getExe' protontricks "protontricks-launch"} $out/bin/peacock-patcher \
--add-flags "--appid 1659040 $out/share/peacock/PeacockPatcher.exe" \
--set PROTON_VERSION "Proton Experimental"
runHook postInstall
'';

meta = {
description = "Replacement server for the HITMAN™ World of Assassination trilogy";
homepage = "https://thepeacockproject.org/";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ marie ];
inherit (nodejs.meta) platforms;
};
})

0 comments on commit 0003e9f

Please sign in to comment.