diff --git a/Makefile b/Makefile index 2120de5..2e4fa9e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -export PREFIX = /usr/local +export PREFIX = $(out) export DATADIR = $(PREFIX)/share/antigrav all: @@ -8,10 +8,10 @@ clean: $(MAKE) -C src clean install: all + mkdir -p "$(PREFIX)"/bin mkdir -p "$(DATADIR)" mv src/antigrav "$(PREFIX)"/bin/ cp data/* "$(DATADIR)"/ - chown -R root:root "$(PREFIX)"/bin/antigrav "$(DATADIR)"/ uninstall: rm -rf "$(DATADIR)" 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..58c96a4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + 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 = antigrav; + antigrav = pkgs.stdenv.mkDerivation { + pname = "antigrav"; + version = "2016-07-13"; + src = ./.; + + nativeBuildInputs = with pkgs; [ copyDesktopItems ]; + buildInputs = with pkgs; [ SDL2 openal libpng libGLU freealut ]; + + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/copy-desktop-items.sh + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/make-desktopitem/default.nix + # + # https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys + # https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html + # + # Available categories: + # https://specifications.freedesktop.org/menu-spec/latest/apa.html + # https://specifications.freedesktop.org/menu-spec/latest/apas02.html + desktopItems = [ + (pkgs.makeDesktopItem { + name = "antigravitaattori"; + icon = "antigravitaattori"; + exec = "antigrav -f -r 1920"; + desktopName = "Antigravitaattori"; + categories = [ "Game" "ArcadeGame" ]; + }) + ]; + + postInstall = "install -D ${./icon_256.png} $out/share/icons/hicolor/256x256/apps/antigravitaattori.png"; + + # SDL files are imported directly as "SDL_xyz.h", not as "SDL2/SDL_xyz.h" + NIX_CFLAGS_COMPILE = "-I${pkgs.lib.getDev pkgs.SDL2}/include/SDL2"; + + # Antigrav calls printf with a string constant instead of a literal. + # https://nixos.org/manual/nixpkgs/stable/#sec-hardening-flags-enabled-by-default + hardeningDisable = [ "format" ]; + }; + } + ); + }; +} diff --git a/icon.xcf b/icon.xcf new file mode 100644 index 0000000..e14b89d Binary files /dev/null and b/icon.xcf differ diff --git a/icon_256.png b/icon_256.png new file mode 100644 index 0000000..8a73665 Binary files /dev/null and b/icon_256.png differ diff --git a/src/Makefile b/src/Makefile index 89f740f..defe1c2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CC = g++ CFLAGS = -O2 -D_REENTRANT -I/usr/include/SDL2 -Itinyxml -DTIXML_USE_STL \ - -DDATADIR="\"$(DATADIR)\"" + -DDATADIR="\"$(DATADIR)\"" $(NIX_CFLAGS_COMPILE) LDFLAGS = -lpng -lalut -lopenal -lGL -lGLU -lSDL2 SOURCES = background.cpp \