about summary refs log tree commit diff
path: root/pkgs/tools/system/runit/default.nix
blob: 2553c07cd6b5c78092df63105952efe7f4d4871e (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
52
53
54
55
56
57
58
59
60
61
{ lib, stdenv, fetchurl, darwin

# Build runit-init as a static binary
, static ? false
}:

stdenv.mkDerivation rec {
  pname = "runit";
  version = "2.1.2";

  src = fetchurl {
    url = "http://smarden.org/runit/${pname}-${version}.tar.gz";
    sha256 = "065s8w62r6chjjs6m9hapcagy33m75nlnxb69vg0f4ngn061dl3g";
  };

  patches = [
    ./fix-ar-ranlib.patch
  ];

  outputs = [ "out" "man" ];

  sourceRoot = "admin/${pname}-${version}";

  doCheck = true;

  buildInputs = lib.optionals static [ stdenv.cc.libc stdenv.cc.libc.static ] ++
    lib.optional stdenv.isDarwin darwin.apple_sdk.libs.utmp;

  postPatch = ''
    sed -i "s,\(#define RUNIT\) .*,\1 \"$out/bin/runit\"," src/runit.h
    # usernamespace sandbox of nix seems to conflict with runit's assumptions
    # about unix users. Therefor skip the check
    sed -i '/.\/chkshsgr/d' src/Makefile
  '' + lib.optionalString (!static) ''
    sed -i 's,-static,,g' src/Makefile
  '';

  preBuild = ''
    cd src

    # Both of these are originally hard-coded to gcc
    echo ${stdenv.cc.targetPrefix}cc > conf-cc
    echo ${stdenv.cc.targetPrefix}cc ${lib.optionalString stdenv.isDarwin "-Xlinker -x "}> conf-ld
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp -t $out/bin $(< ../package/commands)

    mkdir -p $man/share/man
    cp -r ../man $man/share/man/man8
  '';

  meta = with lib; {
    description = "UNIX init scheme with service supervision";
    license = licenses.bsd3;
    homepage = "http://smarden.org/runit";
    maintainers = with maintainers; [ joachifm ];
    platforms = platforms.linux ++ platforms.darwin;
  };
}