From 9c364b72f70375cdd605c7f945f857863ea97ca8 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Fri, 23 Aug 2024 12:03:24 -0500 Subject: [PATCH] first --- .gitignore | 1 + asset-dir.patch | 34 +++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 32 ++++++++++++++++++++++++++ package.nix | 47 +++++++++++++++++++++++++++++++++++++ 5 files changed, 175 insertions(+) create mode 100644 .gitignore create mode 100644 asset-dir.patch create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d6944e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result* diff --git a/asset-dir.patch b/asset-dir.patch new file mode 100644 index 0000000..6ad4ff2 --- /dev/null +++ b/asset-dir.patch @@ -0,0 +1,34 @@ +diff --git a/Makefile b/Makefile +index 5988c93..aaf499e 100644 +--- a/Makefile ++++ b/Makefile +@@ -68,7 +68,7 @@ ifdef REGISTRY_WRITEABLE + CFLAGS += "-DREGISTRY_WRITEABLE=1" + endif + +-CFLAGS += -DASSET_DIR=\"$(DATADIR)\" -DVERSIONSTRING=\"$(VERSION)\" ++CFLAGS += -DASSET_DIR=\"$(DESTDIR)/$(DATADIR)\" -DVERSIONSTRING=\"$(VERSION)\" + CFLAGS += $(SDL_CFLAGS) + CFLAGS += $(CURL_CFLAGS) + # Do not complain about XPMs +diff --git a/src/asset.cpp b/src/asset.cpp +index 999b9db..8c8cd9f 100644 +--- a/src/asset.cpp ++++ b/src/asset.cpp +@@ -135,7 +135,7 @@ int Asset_FindMasterDisk(char *path_out) + // TODO the last ditch paths are bunk -- look for better conventions. + + int err = 255; +- const int count = 5; ++ const int count = 6; + char *paths[count]; + char path[MAX_PATH+1]; + +@@ -150,6 +150,7 @@ int Asset_FindMasterDisk(char *path_out) + strcat(paths[2], "/.local/share/linapple"); + strcpy(paths[3], "/usr/local/share/linapple"); + strcpy(paths[4], "/usr/share/linapple"); ++ strcpy(paths[5], ASSET_DIR); + + for (auto p: paths) { + sprintf(path, "%s/%s", p, ASSET_MASTER_DSK); diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5e1e2f1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1724224976, + "narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9a17299 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "linapple"; + + inputs = { + nixpkgs = { + url = "github:nixos/nixpkgs/nixos-unstable"; + }; + flake-utils = { + url = "github:numtide/flake-utils"; + }; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem + ( + system: let + pkgs = import nixpkgs { + inherit system; + }; + in { + packages = { + linapple = pkgs.callPackage ./package.nix {}; + default = self.packages.${system}.linapple; + }; + } + ); +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..b1ca96d --- /dev/null +++ b/package.nix @@ -0,0 +1,47 @@ +{ + curl, + fetchFromGitHub, + imagemagick7, + lib, + libzip, + pkg-config, + SDL, + SDL_image, + stdenv, + ... +}: +stdenv.mkDerivation (final: { + pname = "linapple"; + version = "2.3.0"; + src = fetchFromGitHub { + owner = "linappleii"; + repo = "linapple"; + rev = "eb1f22e6093bc95cc93756fb905180d01c28656b"; + hash = "sha256-KwUOmjGnfjsQomtn2So/SLoe3XSStD+TbWPsxJaaGcc="; + }; + patches = [ + ./asset-dir.patch + ]; + nativeBuildInputs = [ + imagemagick7 + ]; + buildInputs = [ + curl + libzip + pkg-config + SDL + SDL_image + ]; + makeFlags = [ + "DESTDIR=$(out)" + ]; + # installPhase = '' + # make install DESTDIR=$out + # ''; + + meta = { + homepage = "https://github.com/linappleii/linapple"; + license = lib.licenses.gpl2Plus; + mainProgram = "linapple"; + }; +})