diff --git a/Makefile b/Makefile index f91c824..86c0440 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,8 @@ OBJ = ./bin/portal.o \ WARNINGS=-w -FLAGS=-std=c++11 +RESOURCEDIR = $(out)/share/polly-b-gone/ +FLAGS=-std=c++11 -DRESOURCEDIR="\"$(RESOURCEDIR)\"" $(NIX_CFLAGS_COMPILE) all: g++ -c -g $(SRC) $(INCLUDES) $(WARNINGS) $(FLAGS) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1ff5930 --- /dev/null +++ b/flake.lock @@ -0,0 +1,24 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1683408522, + "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", + "path": "/nix/store/zjpd6dn9kza8zl3l17cwgyifsxbvi3nb-source", + "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cc20472 --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + outputs = { self, nixpkgs }: + let forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + in { + packages = forAllSystems (system: + let pkgs = import nixpkgs { inherit system; }; + in rec { + default = polly-b-gone; + polly-b-gone = pkgs.stdenv.mkDerivation { + pname = "polly-b-gone"; + version = "2020-06-06"; + src = ./.; + + nativeBuildInputs = with pkgs; [ copyDesktopItems ]; + buildInputs = with pkgs; [ libGL libGLU glew freeglut SDL SDL_mixer SDL_image tinyxml ]; + + desktopItems = [ + (pkgs.makeDesktopItem { + name = "polly-b-gone"; + icon = "polly-b-gone"; + exec = "polly-b-gone"; + desktopName = "Polly-B-Gone"; + categories = [ "Game" "ArcadeGame" ]; + }) + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + mv bin/main $out/bin/polly-b-gone + mkdir -p $out/share/polly-b-gone + mv resources/* $out/share/polly-b-gone + + install -Dm444 ${./icon_16.png} $out/share/icons/hicolor/16x16/apps/polly-b-gone.png + install -Dm444 ${./icon_32.png} $out/share/icons/hicolor/32x32/apps/polly-b-gone.png + install -Dm444 ${./icon_128.png} $out/share/icons/hicolor/128x128/apps/polly-b-gone.png + install -Dm444 ${./icon_256.png} $out/share/icons/hicolor/256x256/apps/polly-b-gone.png + + runHook postInstall + ''; + + # SDL files are imported directly as "SDL_xyz.h", not as "SDL/SDL_xyz.h". In + # addition, SDL stopped adding any directories to the include paths on the + # latest unstable. + # TODO Remove first argument again later + NIX_CFLAGS_COMPILE = [ + "-I${pkgs.lib.getDev pkgs.SDL}/include" + "-I${pkgs.lib.getDev pkgs.SDL}/include/SDL" + ]; + }; + } + ); + }; +} diff --git a/icon_128.png b/icon_128.png new file mode 100644 index 0000000..8a603c1 Binary files /dev/null and b/icon_128.png differ diff --git a/icon_16.png b/icon_16.png new file mode 100644 index 0000000..abdc906 Binary files /dev/null and b/icon_16.png differ diff --git a/icon_256.png b/icon_256.png new file mode 100644 index 0000000..bcab6e3 Binary files /dev/null and b/icon_256.png differ diff --git a/icon_32.png b/icon_32.png new file mode 100644 index 0000000..64e2d14 Binary files /dev/null and b/icon_32.png differ diff --git a/src/resource.cpp b/src/resource.cpp index 05f7a49..b04f3cc 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -7,7 +7,7 @@ using namespace mbostock; const char* Resources::path() { - return "resources/"; + return RESOURCEDIR; } const char* Resources::readFile(const char* p) {