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