1{ lib
2, stdenv
3, fetchFromGitHub
4, fixDarwinDylibNames
5}:
6let
7 libExt = stdenv.hostPlatform.extensions.sharedLibrary;
8in
9stdenv.mkDerivation rec {
10 pname = "whereami";
11 version = "unstable-2022-02-18";
12
13 src = fetchFromGitHub {
14 owner = "gpakosz";
15 repo = pname;
16 rev = "ba364cd54fd431c76c045393b6522b4bff547f50";
17 sha256 = "XhRqW0wdXzlmyBf1cjqtQvztuyV4buxVl19Q0uyEOhk=";
18 };
19
20 nativeBuildInputs = lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
21
22 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=strict-prototypes";
23
24 makeFlags = [
25 "-C_gnu-make"
26 "build-library"
27 "binsubdir=platform"
28 ];
29
30 installPhase = ''
31 runHook preInstall
32
33 mkdir -p $out/lib $out/include
34 cp bin/platform/library${libExt} $out/lib/libwhereami${libExt}
35 cp src/whereami.h $out/include/whereami.h
36
37 runHook postInstall
38 '';
39
40 meta = with lib; {
41 description = "Locate the current executable and running module/library";
42 homepage = "https://github.com/gpakosz/whereami";
43 license = with licenses; [ mit wtfpl ];
44 maintainers = with maintainers; [ emilytrau ];
45 platforms = platforms.all;
46 };
47}