Initial commit

This commit is contained in:
Peder Bergebakken Sundt 2023-06-15 01:41:21 +02:00
commit ea10793cf3
5 changed files with 230 additions and 0 deletions

2
.envrc Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
export NIX_CONFIG='builders = ""'

62
flake.lock Normal file
View File

@ -0,0 +1,62 @@
{
"nodes": {
"erosanix": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1686743689,
"narHash": "sha256-3yjiFKYyI+CejMirz1iqdK/uXdtELktq+Dq+3fP/WjM=",
"owner": "emmanuelrosa",
"repo": "erosanix",
"rev": "26b052d36be107db73443039ee3d7303a1b793f0",
"type": "github"
},
"original": {
"owner": "emmanuelrosa",
"repo": "erosanix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1686513595,
"narHash": "sha256-H3JNqj7TEiMx5rd8lRiONvgFZvmf3kmwHI2umDdqgFY=",
"path": "/nix/store/npmjqik8ai6q08kxvp6wg1vz1lskx981-source",
"rev": "bb8b5735d6f7e06b9ddd27de115b0600c1ffbdb4",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"erosanix": "erosanix",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

56
flake.nix Normal file
View File

@ -0,0 +1,56 @@
{
description = "A flake for running pokemon fangames, often via wine";
inputs.erosanix.url = "github:emmanuelrosa/erosanix";
inputs.erosanix.inputs.nixpkgs.follows = "nixpkgs";
outputs = {
self,
nixpkgs,
erosanix,
...
} @ inputs:
{
packages.x86_64-linux = with nixpkgs.legacyPackages.x86_64-linux; rec {
badown = callPackage ./pkgs/badown.nix {};
mediafire-dl = python3Packages.callPackage ./pkgs/mediafire-dl.nix {};
inherit (callPackage ./pkgs/fetchers.nix { inherit badown mediafire-dl; })
fetchFromDrive
;
pokemon = let
callPackage = newScope (erosanix.lib.x86_64-linux // {
wine = wineWowPackages.full;
inherit
fetchFromDrive
;
});
in {
# mkWindowsApp resources:
# - https://github.com/emmanuelrosa/erosanix/tree/master/pkgs/mkwindowsapp
# - https://github.com/emmanuelrosa/sumatrapdf-nix/blob/master/sumatrapdf.nix
project-untamed = callPackage ./games/project-untamed.nix { };
};
};
# garbage-collect
apps.x86_64-linux.gc = {
type = "app";
program = "${erosanix.packages.x86_64-linux.mkwindowsapp-tools}/bin/mkwindows-tools-gc";
};
lib.x86_64-linux = {
inherit (self.packages.x86_64-linux)
fetchFromDrive
;
};
};
}

67
games/project-untamed.nix Normal file
View File

@ -0,0 +1,67 @@
{ lib
, fetchFromDrive
, fetchurl
, mkWindowsApp
, wine
, unzip
, makeDesktopItem
, makeDesktopIcon
, copyDesktopItems
, copyDesktopIcons
}:
let uid = "pkmn-project-untamed";
in mkWindowsApp rec {
pname = "Pokemon Project Untamed";
version = "0.1.3";
meta.homepage = "https://www.reliccastle.com/threads/6122/";
meta.description = "Welcome to the Mazah region as envisioned by Subjectively, tackling modernism versus tradition.";
dontUnpack = true;
src = fetchFromDrive rec {
name = "project-untamed-v${version}.zip";
url = "1chaQzuVLjGEscqLmHJeMJ5J3eNTbTGwj";
hash = "sha256-h4AsKFUOMI/gQSppyoTKreZHvSJJrxzdicJ3w8wXmzo=";
assert_exists = [ name ];
};
inherit wine;
wineArch = "win64";
nativeBuildInputs = [ copyDesktopItems copyDesktopIcons ];
installPhase = ''
runHook preInstall
ln -s $out/bin/.launcher $out/bin/${lib.escapeShellArg pname}
runHook postInstall
'';
winAppInstall = ''
${unzip}/bin/unzip ${src} -d "$WINEPREFIX/drive_c/"
'';
fileMap."$HOME/.local/share/${uid}/AppData"
= "drive_c/users/$USER/AppData/Roaming/project-untamed";
winAppRun = ''
$WINE start /unix "$WINEPREFIX"/drive_c/project-untamed/Game.exe "$ARGS"
'';
desktopItems = [
(makeDesktopItem {
name = pname;
exec = pname;
icon = uid;
desktopName = pname;
categories = ["Game"];
})
];
desktopIcon = makeDesktopIcon {
name = uid;
icoIndex = 0;
src = fetchurl {
url = "https://static.wikia.nocookie.net/minimelos-hive/images/2/2b/Projectuntamedlogotransparent.png";
hash = "sha256-w2T8huYvExQ/Xviwbl8n3xygjQ555NdO48K2kjYxP0o=";
};
};
}

43
pkgs/fetchers.nix Normal file
View File

@ -0,0 +1,43 @@
{ lib
, runCommand
, findutils
, gdown
}:
let
mkFetcher = mkCmd: {
name ? "source",
assert_exists ? [],
url,
hash ? lib.fakeHash,
preferLocalBuild ? true,
}: runCommand name {
outputHash = if hash == "" || hash == null then lib.fakeHash else hash;
outputHashAlgo = null;
outputHashMode = "recursive";
inherit preferLocalBuild;
passthru = { inherit url; };
} ''
cd $(mktemp -d)
${mkCmd url}
${lib.concatMapStringsSep "\n" (fname: ''
if ! test -s ${lib.escapeShellArg fname}; then
echo ERROR: file not found: ${lib.escapeShellArg fname}
echo Files found:
${findutils}/bin/find .
false
fi
'') assert_exists}
if test $(ls | wc -l) -gt 1; then
mkdir $out
fi
cp -v * $out
'';
in {
fetchFromDrive = mkFetcher (url:
"HOME=$(mktemp -d) ${gdown}/bin/gdown ${lib.escapeShellArg url}"
);
}