nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 pkgs,
3 lib,
4 stdenv,
5 fetchzip,
6 ncurses,
7 libX11,
8 libXaw,
9 libXt,
10 libXext,
11 libXmu,
12 makeWrapper,
13 writeScript,
14}:
15
16let
17 setup = writeScript "setup" ''
18 mkdir -p "$ANGBAND_PATH"
19 # Copy all the data files into place
20 cp -ar $1/* "$ANGBAND_PATH"
21 # The copied files are not writable, make them so
22 chmod +w -R "$ANGBAND_PATH"
23 '';
24in
25stdenv.mkDerivation (finalAttrs: {
26 pname = "Sil";
27 version = "1.3.0";
28
29 src = fetchzip {
30 url = "https://www.amirrorclear.net/flowers/game/sil/Sil-130-src.zip";
31 sha256 = "1amp2mr3fxascra0k76sdsvikjh8g76nqh46kka9379zd35lfq8w";
32 stripRoot = false;
33 };
34
35 nativeBuildInputs = [ makeWrapper ];
36 buildInputs = [
37 ncurses
38 libX11
39 libXaw
40 libXt
41 libXext
42 libXmu
43 ];
44
45 sourceRoot = "${finalAttrs.src.name}/Sil/src";
46
47 makefile = "Makefile.std";
48
49 postPatch = ''
50 # Allow usage of ANGBAND_PATH
51 substituteInPlace config.h --replace "#define FIXED_PATHS" ""
52 '';
53
54 preConfigure = ''
55 buildFlagsArray+=("LIBS=-lXaw -lXext -lSM -lICE -lXmu -lXt -lX11 -lncurses")
56 '';
57
58 # Workaround build failure on -fno-common toolchains like upstream
59 # gcc-10. Otherwise build fails as:
60 # ld: main.o:/build/source/Sil/src/externs.h:57: multiple definition of
61 # `mini_screenshot_char'; variable.o:/build/source/Sil/src/externs.h:57: first defined here
62 env.NIX_CFLAGS_COMPILE = "-fcommon";
63
64 installPhase = ''
65 runHook preInstall
66
67 # the makefile doesn't have a sensible install target, so we have to do it ourselves
68 mkdir -p $out/bin
69 cp sil $out/bin/sil
70
71 # Wrap the program to set a user-local ANGBAND_PATH, and run the setup script to copy files into place.
72 # We could just use the options for a user-local save and scores dir, but it tried to write to the
73 # lib directory anyway, so we might as well give everyone a copy
74 wrapProgram $out/bin/sil \
75 --run "export ANGBAND_PATH=\$HOME/.sil" \
76 --run "${setup} ${finalAttrs.src}/Sil/lib"
77
78 runHook postInstall
79 '';
80
81 passthru.tests = {
82 saveDirCreation = pkgs.runCommand "save-dir-creation" { } ''
83 HOME=$(pwd) ${lib.getExe pkgs.sil} --help
84 test -d .sil && touch $out
85 '';
86 };
87
88 meta = {
89 description = "Rogue-like game set in the First Age of Middle-earth";
90 longDescription = ''
91 A game of adventure set in the First Age of Middle-earth, when the world still
92 rang with Elven song and gleamed with Dwarven mail.
93
94 Walk the dark halls of Angband. Slay creatures black and fell. Wrest a shining
95 Silmaril from Morgoth’s iron crown.
96 '';
97 homepage = "http://www.amirrorclear.net/flowers/game/sil/index.html";
98 license = lib.licenses.gpl2Only;
99 maintainers = with lib.maintainers; [
100 michaelpj
101 kenran
102 ];
103 platforms = lib.platforms.linux;
104 mainProgram = "sil";
105 };
106})