Skip to content

Commit

Permalink
build: add basic flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
errfrom authored and pddshk committed Jul 6, 2023
1 parent 3efe93a commit 41e1d34
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ engine_manager
.vscode
*~
src/resources.c
temp
temp
result
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ STD ?= c17
GTK = gtk+-3.0
RSVG = librsvg-2.0
GIO = gio-unix-2.0 gio-2.0
PKGCONF = $(shell which pkg-config)
PKGCONF ?= $(shell which pkg-config)
CFLAGS += -Wall -std=$(STD) -O3 `$(PKGCONF) --cflags $(GTK) $(RSVG) $(GIO)`
LDFLAGS += `$(PKGCONF) --libs $(GTK) $(RSVG) $(GIO)` -lm

Expand Down Expand Up @@ -33,7 +33,10 @@ UI = src/window.glade

all: prepare engine_manager $(OBJECTS)
$(CC) $(CFLAGS) -rdynamic -o GTKChess $(OBJECTS) $(LDFLAGS)
gio set -t string GTKChess metadata::custom-icon file://$(PWD)/src/textures/classic/WKnight.svg
# FIXME: `nix build` fails with error:
# gio: Setting attribute metadata::custom-icon not supported
#
# gio set -t string GTKChess metadata::custom-icon file://$(PWD)/src/textures/classic/WKnight.svg

engine_manager: $(OBJDIR)/engine_manager.o
$(CC) $(CFLAGS) -o engine_manager $< $(LDFLAGS) -pthread
Expand Down Expand Up @@ -69,4 +72,4 @@ check_sources:
clean_check:
rm -f $(TEMPDIR)/*

restore: cleaner clean_check
restore: cleaner clean_check
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
description = "A nix flake for GTK-Chess, UCI chess engine GUI written in C.";
nixConfig = {
extra-experimental-features = [ "nix-command" "flakes" ];
extra-substituters = [ "https://cache.zw3rk.com" ];
extra-trusted-public-keys = [ "loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=" ];

bash-prompt = "\\[\\e[0m\\][\\[\\e[0;2m\\]nix-develop \\[\\e[0;1m\\]gtk-chess@\\[\\033[33m\\]$(git rev-parse --abbrev-ref HEAD) \\[\\e[0;32m\\]\\w\\[\\e[0m\\]]\\[\\e[0m\\]$ \\[\\e[0m\\]";
};

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=22.11";
};

outputs = { self, nixpkgs }: {
defaultPackage.x86_64-linux = self.packages.gtkChess;

packages.gtkChess =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "GTK-Chess";
version = "dev";
src = ./.;
nativeBuildInputs = [ clang gnumake pkg-config which libxml2 ];
buildInputs = [ gtk3 librsvg glib ];
buildPhase = "make all";
installPhase = "mkdir -p $out/bin; cp GTKChess $out/bin";
};
};
}

0 comments on commit 41e1d34

Please sign in to comment.