Skip to content

Instantly share code, notes, and snippets.

@idrisr
Created June 24, 2023 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idrisr/4139147fbabaed4e0ec5769af67b0b12 to your computer and use it in GitHub Desktop.
Save idrisr/4139147fbabaed4e0ec5769af67b0b12 to your computer and use it in GitHub Desktop.
{
inputs.nixpkgs.url = "nixpkgs";
description = "qemu rust game of life";
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
thing = with pkgs;
stdenv.mkDerivation rec {
name = "gameoflife";
src = fetchFromGitHub {
owner = "glitzflitz";
repo = "gameoflife";
rev = "ac17b5987f845f242bc7c9f8f4aea38e8a98f92f";
hash = "sha256-LVYlVwwAWPuKpNcYDmyStlctS/OUa6wIhPXrPzBlp6A=";
};
cargoHash = "sha256-yBoaLqynvYC9ebC0zjd2FmSSd53xzn4ralihtCFubAw=";
nativeBuildInputs = [ makeWrapper qemu ];
PATH = lib.makeBinPath nativeBuildInputs;
# postPatch = ''
# substituteInPlace ./run.sh \
# --replace \
# 'file=gameoflife.bin' \
# 'file=$out/share/gameoflife.bin'
# '';
postInstall = ''
substituteInPlace $out/bin/.run.sh-wrapped \
--replace \
'file=gameoflife.bin' \
'file=$out/share/gameoflife.bin'
'';
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share
mv ./gameoflife.bin $out/share
mv ./README.md $out/bin
mv ./run.sh $out/bin
wrapProgram $out/bin/run.sh \
--prefix PATH : ${lib.makeBinPath nativeBuildInputs}
'';
};
in {
apps.${system}.default = {
program = "${thing}/bin/run.sh";
type = "app";
};
packages.${system}.default = thing;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment