Files
nixpkgs/pkgs/by-name/ru/runit/package.nix
2026-05-24 02:20:54 +02:00

74 lines
1.6 KiB
Nix

{
lib,
stdenv,
fetchurl,
# Build runit-init as a static binary
static ? false,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "runit";
version = "2.3.1";
src = fetchurl {
url = "https://smarden.org/runit/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
hash = "sha256-Y08jyMTR1EAEO+D+ko3fkEYmKJ6Xv+fFgm6TqvLMb+k=";
};
patches = [
./fix-ar-ranlib.patch
];
outputs = [
"out"
"man"
];
sourceRoot = "admin/${finalAttrs.pname}-${finalAttrs.version}";
doCheck = true;
buildInputs = lib.optionals static [
stdenv.cc.libc
stdenv.cc.libc.static
];
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
'';
enableParallelBuilding = true;
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.hostPlatform.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 = {
description = "UNIX init scheme with service supervision";
license = lib.licenses.bsd3;
homepage = "http://smarden.org/runit";
maintainers = [ ];
platforms = lib.platforms.linux ++ lib.platforms.darwin;
mainProgram = "runit";
};
})