1{ stdenv, fetchurl
2
3# Build runit-init as a static binary
4, static ? false
5}:
6
7stdenv.mkDerivation rec {
8 name = "runit-${version}";
9 version = "2.1.2";
10
11 src = fetchurl {
12 url = "http://smarden.org/runit/${name}.tar.gz";
13 sha256 = "065s8w62r6chjjs6m9hapcagy33m75nlnxb69vg0f4ngn061dl3g";
14 };
15
16 outputs = [ "out" "man" ];
17
18 sourceRoot = "admin/${name}";
19
20 doCheck = true;
21
22 buildInputs = stdenv.lib.optionals static [ stdenv.cc.libc stdenv.cc.libc.static ];
23
24 postPatch = ''
25 sed -i "s,\(#define RUNIT\) .*,\1 \"$out/bin/runit\"," src/runit.h
26 # usernamespace sandbox of nix seems to conflict with runit's assumptions
27 # about unix users. Therefor skip the check
28 sed -i '/.\/chkshsgr/d' src/Makefile
29 '' + stdenv.lib.optionalString (!static) ''
30 sed -i 's,-static,,g' src/Makefile
31 '';
32
33 preBuild = ''
34 cd src
35
36 # Both of these are originally hard-coded to gcc
37 echo cc > conf-cc
38 echo cc > conf-ld
39 '';
40
41 installPhase = ''
42 mkdir -p $out/bin
43 cp -t $out/bin $(< ../package/commands)
44
45 mkdir -p $man/share/man
46 cp -r ../man $man/share/man/man8
47 '';
48
49 meta = with stdenv.lib; {
50 description = "UNIX init scheme with service supervision";
51 license = licenses.bsd3;
52 homepage = http://smarden.org/runit;
53 maintainers = with maintainers; [ rickynils joachifm ];
54 platforms = platforms.unix;
55 };
56}