nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 copyPkgconfigItems,
5 fetchFromGitHub,
6 makePkgconfigItem,
7 pkg-config,
8 SDL,
9 SDL_image,
10 SDL_mixer,
11 SDL_net,
12 SDL_ttf,
13}:
14
15stdenv.mkDerivation (finalAttrs: {
16 pname = "sparrow3d";
17 version = "unstable-2020-10-06";
18
19 outputs = [
20 "out"
21 "dev"
22 ];
23
24 src = fetchFromGitHub {
25 owner = "theZiz";
26 repo = "sparrow3d";
27 rev = "2033349d7adeba34bda2c442e1fec22377471134";
28 hash = "sha256-28j5nbTYBrMN8BQ6XrTlO1D8Viw+RiT3MAl99BAbhR4=";
29 };
30
31 pkgconfigItems = [
32 (makePkgconfigItem rec {
33 name = "sparrow3d";
34 inherit (finalAttrs) version;
35 inherit (finalAttrs.meta) description;
36
37 cflags = [ "-isystem${variables.includedir}" ];
38 libs = [
39 "-L${variables.libdir}"
40 "-lsparrow3d"
41 "-lsparrowNet"
42 "-lsparrowSound"
43 ];
44 variables = rec {
45 prefix = "@dev@";
46 exec_prefix = "@out@";
47 includedir = "${prefix}/include";
48 libdir = "${exec_prefix}/lib";
49 };
50 })
51 ];
52
53 nativeBuildInputs = [
54 copyPkgconfigItems
55 pkg-config
56 ];
57
58 propagatedBuildInputs = [
59 (lib.getDev SDL)
60 SDL_image
61 SDL_ttf
62 SDL_mixer
63 SDL_net
64 ];
65
66 postConfigure = ''
67 NIX_CFLAGS_COMPILE=$(pkg-config --cflags SDL_image SDL_ttf SDL_mixer SDL_net)
68 '';
69
70 buildFlags = [ "dynamic" ];
71
72 installPhase = ''
73 runHook preInstall
74
75 mkdir -p $out/lib
76 cp libsparrow{3d,Net,Sound}.so $out/lib
77
78 mkdir -p $dev/include
79 cp sparrow*.h $dev/include
80
81 runHook postInstall
82 '';
83
84 doCheck = true;
85
86 checkPhase = ''
87 runHook preCheck
88
89 make all_no_static
90 ./testfile.sh
91
92 runHook postCheck
93 '';
94
95 meta = {
96 homepage = "https://github.com/theZiz/sparrow3d";
97 description = "Software renderer for different open handhelds like the gp2x, wiz, caanoo and pandora";
98 license = lib.licenses.lgpl21;
99 maintainers = with lib.maintainers; [ colinsane ];
100 platforms = lib.platforms.linux;
101 };
102})