about summary refs log tree commit diff
path: root/pkgs/games/xsokoban/default.nix
blob: 8cdf07bb3063ddaaec1009295ed5eaa19472cc99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
a :
let
  fetchurl = a.fetchurl;

  version = a.lib.attrByPath ["version"] "3.3c" a;
  buildInputs = with a; [
    a.libX11 a.xproto a.libXpm a.libXt
  ];
in
rec {
  src = fetchurl {
    url = "http://www.cs.cornell.edu/andru/release/xsokoban-${version}.tar.gz";
    sha256 = "006lp8y22b9pi81x1a9ldfgkl1fbmkdzfw0lqw5y9svmisbafbr9";
  };

  inherit buildInputs;
  configureFlags = [];

  /* doConfigure should be removed if not needed */
  phaseNames = ["preConfigure" "doConfigure" "preBuild" "doMakeInstall"];

  preConfigure = a.fullDepEntry (''
    sed -e 's/getline/my_getline/' -i score.c
    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${a.libXpm}/include/X11"
    for i in  $NIX_CFLAGS_COMPILE; do echo $i; ls ''${i#-I}; done
    chmod a+rw config.h
    echo '#define HERE "@nixos-packaged"' >> config.h
    echo '#define WWW 0' >> config.h
    echo '#define OWNER "'$(whoami)'"' >> config.h
    echo '#define ROOTDIR "'$out/lib/xsokoban'"' >> config.h
    echo '#define ANYLEVEL 1' >> config.h
    echo '#define SCOREFILE ".xsokoban-score"' >> config.h
    echo '#define LOCKFILE ".xsokoban-score-lock"' >> config.h

    sed -e 's/getpass[(][^)]*[)]/PASSWORD/' -i main.c
    sed -e '/if [(]owner[)]/iowner=1;' -i main.c
  '') ["minInit" "doUnpack"];

  preBuild = a.fullDepEntry (''
    sed -e "s@/usr/local/@$out/@" -i Makefile
    sed -e "s@ /bin/@ @" -i Makefile
    mkdir -p $out/bin $out/share $out/man/man1 $out/lib
  '') ["minInit" "doConfigure" "defEnsureDir"];

  name = "xsokoban-" + version;
  meta = {
    description = "X sokoban";
    license = a.stdenv.lib.licenses.publicDomain;
    maintainers = [ a.stdenv.lib.maintainers.raskin ];
  };
}