@@ -1,46 +1,75 @@
1−{ stdenv, pkgs, fetchgit, autoconf, sbcl, lispPackages, xdpyinfo, texinfo4, makeWrapper, stumpwmContrib }:
1+{ stdenv, pkgs, fetchgit, autoconf, sbcl, lispPackages, xdpyinfo, texinfo4
2+, makeWrapper , rlwrap, gnused, gnugrep, coreutils, xprop
3+, extraModulePaths ? [] }:
24
35let
4− tag = "0.9.9";
6+ version = "0.9.9";
7+ contrib = (fetchgit {
8+ url = "https://github.com/stumpwm/stumpwm-contrib.git";
9+ rev = "e139885fffcedaeba4b263e4575daae4364cad52";
10+ sha256 = "fe75bb27538a56f2d213fb21e06a8983699e129a10da7014ddcf6eed5cd965f8";
11+ });
512in
6−
713stdenv.mkDerivation rec {
8− name = "stumpwm-${tag}";
14+ name = "stumpwm-${version}";
15+
16+ src = fetchgit {
17+ url = "https://github.com/stumpwm/stumpwm";
18+ rev = "refs/tags/${version}";
19+ sha256 = "05fkng2wlmhy3kb9zhrrv9zpa16g2p91p5y0wvmwkppy04cw04ps";
20+ };
21+
22+ buildInputs = [
23+ texinfo4 makeWrapper autoconf
24+ sbcl
25+ lispPackages.clx
26+ lispPackages.cl-ppcre
27+ xdpyinfo
28+ ];
29+
30+ # NOTE: The patch needs an update for the next release.
31+ # `(stumpwm:set-module-dir "@MODULE_DIR@")' needs to be in it.
32+ patches = [ ./fix-module-path.patch ];
33+
34+ # Stripping destroys the generated SBCL image
35+ dontStrip = true;
936
10− src = fetchgit {
11− url = "https://github.com/stumpwm/stumpwm";
12− rev = "refs/tags/${tag}";
13− sha256 = "05fkng2wlmhy3kb9zhrrv9zpa16g2p91p5y0wvmwkppy04cw04ps";
14− };
37+ configurePhase = ''
38+ ./autogen.sh
39+ ./configure --prefix=$out --with-module-dir=$out/share/stumpwm/modules
40+ '';
1541
16− buildInputs = [ texinfo4 autoconf lispPackages.clx lispPackages.cl-ppcre sbcl makeWrapper stumpwmContrib ];
42+ preBuild = ''
43+ cp -r --no-preserve=mode ${contrib} modules
44+ '';
1745
18− phases = [ "unpackPhase" "preConfigurePhase" "configurePhase" "installPhase" ];
46+ installPhase = ''
47+ mkdir -pv $out/bin
48+ make install
1949
20− preConfigurePhase = ''
21− $src/autogen.sh
22− mkdir -pv $out/bin
23− '';
50+ mkdir -p $out/share/stumpwm/modules
51+ cp -r modules/* $out/share/stumpwm/modules/
52+ for d in ${stdenv.lib.concatStringsSep " " extraModulePaths}; do
53+ cp -r --no-preserve=mode "$d" $out/share/stumpwm/modules/
54+ done
2455
25− configurePhase = ''
26− ./configure --prefix=$out --with-contrib-dir=${stumpwmContrib}/contrib
27− '';
56+ # Copy stumpish;
57+ cp $out/share/stumpwm/modules/util/stumpish/stumpish $out/bin/
58+ chmod +x $out/bin/stumpish
59+ wrapProgram $out/bin/stumpish \
60+ --prefix PATH ":" "${rlwrap}/bin:${gnused}/bin:${gnugrep}/bin:${coreutils}/bin:${xprop}/bin"
2861
29− installPhase = ''
30− make
31− make install
32− # For some reason, stumpwmContrib is not retained as a runtime
33− # dependency (probably because $out/bin/stumpwm is compressed or
34− # obfuscated in some way). Thus we add an explicit reference here.
35− mkdir $out/nix-support
36− echo ${stumpwmContrib} > $out/nix-support/stumpwm-contrib
37− '';
62+ # Paths in the compressed image $out/bin/stumpwm are not
63+ # recognized by Nix. Add explicit reference here.
64+ mkdir $out/nix-support
65+ echo ${xdpyinfo} > $out/nix-support/xdpyinfo
66+ '';
3867
3968 meta = with stdenv.lib; {
4069 description = "A tiling window manager for X11";
4170 homepage = https://github.com/stumpwm/;
4271 license = licenses.gpl2Plus;
43− maintainers = with maintainers; [ _1126 ];
72+ maintainers = with maintainers; [ _1126 the-kenny ];
4473 platforms = platforms.linux;
4574 };
4675}