btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / ru / runit / package.nix
blobf300ab2a33ac0264765c05171560921f40786625
1 { lib, stdenv, fetchurl, darwin
3 # Build runit-init as a static binary
4 , static ? false
5 }:
7 stdenv.mkDerivation rec {
8   pname = "runit";
9   version = "2.2.0";
11   src = fetchurl {
12     url = "http://smarden.org/runit/${pname}-${version}.tar.gz";
13     sha256 = "sha256-le9NKGi5eMcXn+R5AeXFeOEc8nPSkr1iCL06fMsCkpA=";
14   };
16   patches = [
17     ./fix-ar-ranlib.patch
18   ];
20   outputs = [ "out" "man" ];
22   sourceRoot = "admin/${pname}-${version}";
24   doCheck = true;
26   buildInputs = lib.optionals static [ stdenv.cc.libc stdenv.cc.libc.static ] ++
27     lib.optional stdenv.hostPlatform.isDarwin darwin.apple_sdk.libs.utmp;
29   postPatch = ''
30     sed -i "s,\(#define RUNIT\) .*,\1 \"$out/bin/runit\"," src/runit.h
31     # usernamespace sandbox of nix seems to conflict with runit's assumptions
32     # about unix users. Therefor skip the check
33     sed -i '/.\/chkshsgr/d' src/Makefile
34   '' + lib.optionalString (!static) ''
35     sed -i 's,-static,,g' src/Makefile
36   '';
38   preBuild = ''
39     cd src
41     # Both of these are originally hard-coded to gcc
42     echo ${stdenv.cc.targetPrefix}cc > conf-cc
43     echo ${stdenv.cc.targetPrefix}cc ${lib.optionalString stdenv.hostPlatform.isDarwin "-Xlinker -x "}> conf-ld
44   '';
46   installPhase = ''
47     mkdir -p $out/bin
48     cp -t $out/bin $(< ../package/commands)
50     mkdir -p $man/share/man
51     cp -r ../man $man/share/man/man8
52   '';
54   meta = with lib; {
55     description = "UNIX init scheme with service supervision";
56     license = licenses.bsd3;
57     homepage = "http://smarden.org/runit";
58     maintainers = with maintainers; [ joachifm ];
59     platforms = platforms.linux ++ platforms.darwin;
60   };