Skip to content

add flake.nix and fix issues with build system variable expansion - #143

Closed
km-clay wants to merge 3 commits into
thpatch:masterfrom
km-clay:nix-flake
Closed

km-clay wants to merge 3 commits into
thpatch:masterfrom
km-clay:nix-flake

Conversation

@km-clay

@km-clay km-clay commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

I wrote a nix flake that builds thtk.

while I was working on it I found that the installed thtk.pc is broken. building current master with a simple /usr/local prefix:

prefix = /usr/local
exec_prefix =
includedir = /include
libdir = /lib64

Libs: -L -lthtk
Cflags: -I

pkg-config --cflags --libs thtk returns -I -L -lthtk, so consumers get no include path and no library path.

this is caused by thtk/CMakeLists.txt:30 calling configure_file() without passing @ONLY as an argument, so CMake substitutes both variable forms: @VAR@ and ${VAR}. The pkg-config variable references in thtk/thtk.pc.in get eaten by CMake eagerly expanding them.

also, the paths in thtk.pc.in were built as ${prefix}/@CMAKE_INSTALL_INCLUDEDIR@, which assumes those variables are relative. replacing the path construction with @CMAKE_INSTALL_FULL_INCLUDEDIR@ handles absolute paths correctly. Same for the LIBDIR path construction.

Notably, the currently open nixpkgs thtk pull request includes a hack designed to work around this issue. Not entirely relevant, but wanted to point it out to prove that it's not just an issue with my environment. (I also based the derivation in the flake on the one in that PR)

This PR includes both the fixes for the build system and the nix flake.

@DankRank DankRank self-assigned this Sep 27, 2026
@DankRank DankRank closed this in c61692a Oct 7, 2026
@DankRank

DankRank commented Oct 7, 2026

Copy link
Copy Markdown
Member

Merged the first two commits, thanks for your contribution. The flake should go in nixpkgs, tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants