push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
{
lib,
stdenv,
fetchFromSourcehut,
}:
{
# : string
pname,
# : string
version,
# : string
sha256,
# : string
description,
# : list Maintainer
maintainers,
# : license
license ? lib.licenses.isc,
# : string
owner ? "~flexibeast",
# : string
rev ? "v${version}",
}:
let
manDir = "${placeholder "out"}/share/man";
src = fetchFromSourcehut {
inherit owner rev sha256;
repo = pname;
};
in
stdenv.mkDerivation {
inherit pname version src;
makeFlags = [
"MAN_DIR=${manDir}"
];
dontBuild = true;
meta = with lib; {
inherit description license maintainers;
inherit (src.meta) homepage;
platforms = platforms.all;
};
}

View File

@@ -0,0 +1,179 @@
{
lib,
stdenv,
cleanPackaging,
fetchurl,
nix-update-script,
}:
{
# : string
pname,
# : string
version,
# : string
sha256 ? lib.fakeSha256,
# : drv | null
manpages ? null,
# : string
description,
# : list Platform
platforms ? lib.platforms.all,
# : list string
outputs ? [
"bin"
"lib"
"dev"
"doc"
"out"
],
# TODO(Profpatsch): automatically infer most of these
# : list string
configureFlags,
# : string
postConfigure ? null,
# mostly for moving and deleting files from the build directory
# : lines
postInstall,
# : list Maintainer
maintainers ? [ ],
# : passthru arguments (e.g. tests)
passthru ? { },
# : attributes to be merged into meta
broken ? false,
}:
let
# File globs that can always be deleted
commonNoiseFiles = [
".gitignore"
"Makefile"
"INSTALL"
"configure"
"patch-for-solaris"
"src/**/*"
"tools/**/*"
"package/**/*"
"config.mak"
];
# File globs that should be moved to $doc
commonMetaFiles = [
"COPYING"
"AUTHORS"
"NEWS"
"CHANGELOG"
"README"
"README.*"
"DCO"
"CONTRIBUTING"
];
in
stdenv.mkDerivation {
inherit pname version;
src = fetchurl {
url = "https://skarnet.org/software/${pname}/${pname}-${version}.tar.gz";
inherit sha256;
};
outputs =
if manpages == null then
outputs
else
assert (
lib.assertMsg (!lib.elem "man" outputs)
"If you pass `manpages` to `skawarePackages.buildPackage`, you cannot have a `man` output already!"
);
# insert as early as possible, but keep the first element
if lib.length outputs > 0 then
[
(lib.head outputs)
"man"
]
++ lib.tail outputs
else
[ "man" ];
dontDisableStatic = true;
enableParallelBuilding = true;
configureFlags =
configureFlags
++ [
"--enable-absolute-paths"
# We assume every nix-based cross target has urandom.
# This might not hold for e.g. BSD.
"--with-sysdep-devurandom=yes"
(if stdenv.hostPlatform.isDarwin then "--disable-shared" else "--enable-shared")
]
# On darwin, the target triplet from -dumpmachine includes version number,
# but skarnet.org software uses the triplet to test binary compatibility.
# Explicitly setting target ensures code can be compiled against a skalibs
# binary built on a different version of darwin.
# http://www.skarnet.org/cgi-bin/archive.cgi?1:mss:623:heiodchokfjdkonfhdph
++ (lib.optional stdenv.hostPlatform.isDarwin "--build=${stdenv.hostPlatform.system}");
inherit postConfigure;
makeFlags = lib.optionals stdenv.cc.isClang [
"AR=${stdenv.cc.targetPrefix}ar"
"RANLIB=${stdenv.cc.targetPrefix}ranlib"
];
# TODO(Profpatsch): ensure that there is always a $doc output!
postInstall = ''
echo "Cleaning & moving common files"
${
cleanPackaging.commonFileActions {
noiseFiles = commonNoiseFiles;
docFiles = commonMetaFiles;
}
} $doc/share/doc/${pname}
${
if manpages == null then
''echo "no manpages for this package"''
else
''
echo "copying manpages"
cp -vr ${manpages} $man
''
}
${postInstall}
'';
postFixup = ''
${cleanPackaging.checkForRemainingFiles}
'';
passthru = {
updateScript = nix-update-script {
extraArgs = [
"--url"
"https://github.com/skarnet/${pname}"
"--override-filename"
"pkgs/development/skaware-packages/${pname}/default.nix"
];
};
}
// passthru
// (if manpages == null then { } else { inherit manpages; });
meta = {
homepage = "https://skarnet.org/software/${pname}/";
inherit broken description platforms;
license = lib.licenses.isc;
maintainers =
with lib.maintainers;
[
pmahoney
Profpatsch
qyliss
]
++ maintainers;
};
}

View File

@@ -0,0 +1,58 @@
# set of utilities that assure the cwd of a build
# is completely clean after the build, meaning all
# files were either discarded or moved to outputs.
# This ensures nothing is forgotten and new files
# are correctly handled on update.
{
lib,
stdenv,
file,
writeScript,
}:
let
globWith = lib.concatMapStringsSep "\n";
rmNoise = noiseGlobs: globWith (f: "rm -rf ${f}") noiseGlobs;
mvDoc = docGlobs: globWith (f: ''mv ${f} "$DOCDIR" 2>/dev/null || true'') docGlobs;
# Shell script that implements common move & remove actions
# $1 is the doc directory (will be created).
# Best used in conjunction with checkForRemainingFiles
commonFileActions =
{
# list of fileglobs that are removed from the source dir
noiseFiles,
# files that are moved to the doc directory ($1)
# TODO(Profpatsch): allow to set target dir with
# { glob = …; to = "html" } (relative to docdir)
docFiles,
}:
writeScript "common-file-actions.sh" ''
#!${stdenv.shell}
set -e
DOCDIR="''${1?commonFileActions: DOCDIR as argv[1] required}"
shopt -s globstar extglob nullglob
mkdir -p "$DOCDIR"
${mvDoc docFiles}
${rmNoise noiseFiles}
'';
# Shell script to check whether the build directory is empty.
# If there are still files remaining, exit 1 with a helpful
# listing of all remaining files and their types.
checkForRemainingFiles = writeScript "check-for-remaining-files.sh" ''
#!${stdenv.shell}
echo "Checking for remaining source files"
rem=$(find -mindepth 1 -xtype f -print0 \
| tee $TMP/remaining-files)
if [[ "$rem" != "" ]]; then
echo "ERROR: These files should be either moved or deleted:"
cat $TMP/remaining-files | xargs -0 ${file}/bin/file
exit 1
fi
'';
in
{
inherit commonFileActions checkForRemainingFiles;
}

View File

@@ -0,0 +1,43 @@
{ lib, pkgs }:
lib.makeScope pkgs.newScope (
self:
let
inherit (self) callPackage;
in
{
buildManPages = callPackage ./build-skaware-man-pages.nix { };
buildPackage = callPackage ./build-skaware-package.nix { };
cleanPackaging = callPackage ./clean-packaging.nix { };
# execline
execline = callPackage ./execline { };
# servers & tools
mdevd = callPackage ./mdevd { };
nsss = callPackage ./nsss { };
tipidee = callPackage ./tipidee { };
utmps = callPackage ./utmps { };
# libs
skalibs = callPackage ./skalibs { };
skalibs_2_10 = callPackage ./skalibs/2_10.nix { };
sdnotify-wrapper = callPackage ./sdnotify-wrapper { };
# s6 tooling
s6 = callPackage ./s6 { };
s6-dns = callPackage ./s6-dns { };
s6-linux-init = callPackage ./s6-linux-init { };
s6-linux-utils = callPackage ./s6-linux-utils { };
s6-networking = callPackage ./s6-networking { };
s6-portable-utils = callPackage ./s6-portable-utils { };
s6-rc = callPackage ./s6-rc { };
# manpages (DEPRECATED, they are added directly to the packages now)
execline-man-pages = self.execline.passthru.manpages;
s6-man-pages = self.s6.passthru.manpages;
s6-networking-man-pages = self.s6-networking.passthru.manpages;
s6-portable-utils-man-pages = self.s6-portable-utils.passthru.manpages;
s6-rc-man-pages = self.s6-rc.passthru.manpages;
}
)

View File

@@ -0,0 +1,99 @@
{
lib,
skawarePackages,
skalibs,
execline,
writeTextFile,
}:
let
version = "2.9.7.0";
in
skawarePackages.buildPackage {
inherit version;
pname = "execline";
# ATTN: also check whether there is a new manpages version
sha256 = "sha256-c8kWDvyZQHjY6lSA+RYb/Rs88LYff6q3BKsYmFF9Agc=";
# Maintainer of manpages uses following versioning scheme: for every
# upstream $version he tags manpages release as ${version}.1, and,
# in case of extra fixes to manpages, new tags in form ${version}.2,
# ${version}.3 and so on are created.
manpages = skawarePackages.buildManPages {
pname = "execline-man-pages";
version = "2.9.6.1.1";
sha256 = "sha256-bj+74zTkGKLdLEb1k4iHfNI1lAuxLBASc5++m17Y0O8=";
description = "Port of the documentation for the execline suite to mdoc";
maintainers = [ lib.maintainers.sternenseemann ];
};
description = "Small scripting language, to be used in place of a shell in non-interactive scripts";
outputs = [
"bin"
"lib"
"dev"
"doc"
"out"
];
# TODO: nsss support
configureFlags = [
"--libdir=\${lib}/lib"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all execline executables from build directory
rm $(find -type f -mindepth 1 -maxdepth 1 -executable)
rm libexecline.*
mv doc $doc/share/doc/execline/html
mv examples $doc/share/doc/execline/examples
mv $bin/bin/execlineb $bin/bin/.execlineb-wrapped
# A wrapper around execlineb, which provides all execline
# tools on `execlineb`s PATH.
# It is implemented as a C script, because on non-Linux,
# nested shebang lines are not supported.
# The -lskarnet has to come at the end to support static builds.
$CC \
-O \
-Wall -Wpedantic \
-D "EXECLINEB_PATH()=\"$bin/bin/.execlineb-wrapped\"" \
-D "EXECLINE_BIN_PATH()=\"$bin/bin\"" \
-I "${skalibs.dev}/include" \
-L "${skalibs.lib}/lib" \
-o "$bin/bin/execlineb" \
${./execlineb-wrapper.c} \
-lskarnet
'';
# Write an execline script.
# Documented in ../../../../doc/build-helpers/trivial-build-helpers.chapter.md
passthru.writeScript =
name: options: script:
writeTextFile {
inherit name;
text = ''
#!${execline}/bin/execlineb ${toString options}
${script}
'';
executable = true;
derivationArgs.nativeBuildInputs = [ execline ];
checkPhase = ''
echo redirfd -w 1 /dev/null echo >test.el
cat <$target >>test.el
execlineb -W test.el
'';
};
}

View File

@@ -0,0 +1,51 @@
/*
* A wrapper around execlineb, which provides all execline
* tools on execlinebs PATH.
* It is implemented as a C program, because on non-Linux,
* nested shebang lines are not supported.
*/
#include <stdlib.h>
#include <string.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <skalibs/strerr2.h>
#include <skalibs/env.h>
#include <skalibs/exec.h>
#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
// macros from outside
/* const char* EXECLINEB_PATH; */
/* const char* EXECLINE_BIN_PATH; */
int main(int argc, char const* argv[], char const *const *envp)
{
PROG = "execlineb-wrapper";
char const* path = getenv("PATH");
stralloc path_modif = STRALLOC_ZERO;
// modify PATH if unset or EXECLINEB_BIN_PATH is not yet there
if ( !path || ! strstr(path, EXECLINE_BIN_PATH())) {
// prepend our execline path
if ( ! stralloc_cats(&path_modif, "PATH=")
|| ! stralloc_cats(&path_modif, EXECLINE_BIN_PATH()) ) dienomem();
// old path was not empty
if ( path && path[0] ) {
if ( ! stralloc_catb(&path_modif, ":", 1)
|| ! stralloc_cats(&path_modif, path) ) dienomem();
}
// append final \0
if ( ! stralloc_0(&path_modif) ) dienomem();
}
// exec into execlineb and append path_modif to the environment
xmexec_aem(
EXECLINEB_PATH(),
argv,
envp,
path_modif.s, path_modif.len
);
}

View File

@@ -0,0 +1,36 @@
{
lib,
skawarePackages,
skalibs,
}:
skawarePackages.buildPackage {
pname = "mdevd";
version = "0.1.7.0";
sha256 = "sha256-7JZu7DmHnzPHhTQzcwIcRPiHyDagj8rx1jQS472/yjI=";
description = "mdev-compatible Linux hotplug manager daemon";
platforms = lib.platforms.linux;
outputs = [
"bin"
"out"
"dev"
"doc"
];
configureFlags = [
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all mdevd executables from build directory
rm $(find -type f -mindepth 1 -maxdepth 1 -executable)
rm libmdevd.*
mv doc $doc/share/doc/mdevd/html
mv examples $doc/share/doc/mdevd/examples
'';
}

View File

@@ -0,0 +1,31 @@
{ skawarePackages, skalibs }:
skawarePackages.buildPackage {
pname = "nsss";
version = "0.2.1.0";
sha256 = "sha256-8iGjHBzuiB6ZKobf4pYzIlPHqfxl9g2IgpzI6JSEIPQ=";
description = "Implementation of a subset of the pwd.h, group.h and shadow.h family of functions";
# TODO: nsss support
configureFlags = [
"--libdir=\${lib}/lib"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all nsss executables from build directory
rm $(find -name "nsssd-*" -type f -mindepth 1 -maxdepth 1 -executable)
rm libnsss.* libnsssd.*
mv doc $doc/share/doc/nsss/html
mv examples $doc/share/doc/nsss/examples
'';
}

View File

@@ -0,0 +1,39 @@
{ skawarePackages, skalibs }:
skawarePackages.buildPackage {
pname = "s6-dns";
version = "2.4.1.0";
sha256 = "sha256-tjCFGfEJpnRpxKqvqd8fAJrQlh+nmP/Dj4lVh+aTVyk=";
description = "Suite of DNS client programs and libraries for Unix systems";
outputs = [
"bin"
"lib"
"dev"
"doc"
"out"
];
configureFlags = [
"--libdir=\${lib}/lib"
"--libexecdir=\${lib}/libexec"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all s6-dns executables from build directory
rm $(find -type f -mindepth 1 -maxdepth 1 -executable)
rm libs6dns.*
rm libskadns.*
mv doc $doc/share/doc/s6-dns/html
'';
}

View File

@@ -0,0 +1,58 @@
{
lib,
stdenv,
skawarePackages,
skalibs,
execline,
s6,
targetPackages,
}:
skawarePackages.buildPackage {
pname = "s6-linux-init";
version = "1.1.3.0";
sha256 = "sha256-0RtZa3GawTT3frGUUJB9H+bYS0rcNtRO90jb5VSHs+0=";
description = "Set of minimalistic tools used to create a s6-based init system, including a /sbin/init binary, on a Linux kernel";
platforms = lib.platforms.linux;
outputs = [
"bin"
"dev"
"doc"
"out"
];
configureFlags = [
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-include=${execline.dev}/include"
"--with-include=${s6.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-lib=${s6.out}/lib"
"--with-lib=${execline.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
"--with-dynlib=${execline.lib}/lib"
"--with-dynlib=${s6.out}/lib"
];
# See ../s6-rc/default.nix for an explanation
postConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
substituteInPlace src/init/s6-linux-init-maker.c \
--replace-fail '<execline/config.h>' '"${targetPackages.execline.dev}/include/execline/config.h"' \
--replace-fail '<s6/config.h>' '"${targetPackages.s6.dev}/include/s6/config.h"' \
--replace-fail '<s6-linux-init/config.h>' '"${targetPackages.s6-linux-init.dev}/include/s6-linux-init/config.h"'
'';
postInstall = ''
# remove all s6 executables from build directory
rm $(find -name "s6-*" -type f -mindepth 1 -maxdepth 1 -executable)
rm libs6_linux_init.* libhpr.*
rm -rf skel
mv doc $doc/share/doc/s6-linux-init/html
'';
}

View File

@@ -0,0 +1,40 @@
{
lib,
skawarePackages,
skalibs,
}:
skawarePackages.buildPackage {
pname = "s6-linux-utils";
version = "2.6.3.0";
sha256 = "sha256-fiScNsc7mev8H5qaTDGL52tGHrxT05Ut6QZMz6tABzk=";
description = "Set of minimalistic Linux-specific system utilities";
platforms = lib.platforms.linux;
outputs = [
"bin"
"dev"
"doc"
"out"
];
# TODO: nsss support
configureFlags = [
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all s6 executables from build directory
rm $(find -name "s6-*" -type f -mindepth 1 -maxdepth 1 -executable) rngseed
rm libs6ps.a.xyzzy
mv doc $doc/share/doc/s6-linux-utils/html
'';
}

View File

@@ -0,0 +1,85 @@
{
lib,
skawarePackages,
skalibs,
execline,
s6,
s6-dns,
# Whether to build the TLS/SSL tools and what library to use
# acceptable values: "bearssl", "libressl", false
sslSupport ? "bearssl",
libressl,
bearssl,
}:
let
sslSupportEnabled = sslSupport != false;
sslLibs = {
libressl = libressl;
bearssl = bearssl;
};
in
assert sslSupportEnabled -> sslLibs ? ${sslSupport};
skawarePackages.buildPackage {
pname = "s6-networking";
version = "2.7.1.0";
sha256 = "sha256-p7M0l+cpIaWdTB/GfOXMdL0GXgkQW/Gnnx/HPPmgZZI=";
manpages = skawarePackages.buildManPages {
pname = "s6-networking-man-pages";
version = "2.7.0.4.1";
sha256 = "sha256-ocYUZVnkuhO/1qgW3mSooZRoqqch1SgIRoygS3AjeZI=";
description = "Port of the documentation for the s6-networking suite to mdoc";
maintainers = [ lib.maintainers.sternenseemann ];
};
description = "Suite of small networking utilities for Unix systems";
outputs = [
"bin"
"lib"
"dev"
"doc"
"out"
];
# TODO: nsss support
configureFlags = [
"--libdir=\${lib}/lib"
"--libexecdir=\${lib}/libexec"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-include=${execline.dev}/include"
"--with-include=${s6.dev}/include"
"--with-include=${s6-dns.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-lib=${execline.lib}/lib"
"--with-lib=${s6.out}/lib"
"--with-lib=${s6-dns.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
"--with-dynlib=${execline.lib}/lib"
"--with-dynlib=${s6.out}/lib"
"--with-dynlib=${s6-dns.lib}/lib"
]
++ (lib.optionals sslSupportEnabled [
"--enable-ssl=${sslSupport}"
"--with-include=${lib.getDev sslLibs.${sslSupport}}/include"
"--with-lib=${lib.getLib sslLibs.${sslSupport}}/lib"
"--with-dynlib=${lib.getLib sslLibs.${sslSupport}}/lib"
]);
postInstall = ''
# remove all s6 executables from build directory
rm $(find -name "s6-*" -type f -mindepth 1 -maxdepth 1 -executable)
rm libs6net.* libstls.* libs6tls.* libsbearssl.*
mv doc $doc/share/doc/s6-networking/html
'';
}

View File

@@ -0,0 +1,46 @@
{
lib,
skawarePackages,
skalibs,
}:
skawarePackages.buildPackage {
pname = "s6-portable-utils";
version = "2.3.1.0";
sha256 = "sha256-BCRKqHrixBLUmZdptec8tCivugwuiqkhWzo2574qgPk=";
manpages = skawarePackages.buildManPages {
pname = "s6-portable-utils-man-pages";
version = "2.3.0.4.1";
sha256 = "sha256-LbXa+fecxYyFdVmEHT8ch4Y8Pf1YIyd9Gia3zujxUgs=";
description = "Port of the documentation for the s6-portable-utils suite to mdoc";
maintainers = [ lib.maintainers.somasis ];
};
description = "Set of tiny general Unix utilities optimized for simplicity and small size";
outputs = [
"bin"
"dev"
"doc"
"out"
];
configureFlags = [
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all s6 executables from build directory
rm $(find -name "s6-*" -type f -mindepth 1 -maxdepth 1 -executable)
rm seekablepipe
mv doc $doc/share/doc/s6-portable-utils/html
'';
}

View File

@@ -0,0 +1,81 @@
{
lib,
stdenv,
skawarePackages,
targetPackages,
skalibs,
execline,
s6,
}:
skawarePackages.buildPackage {
pname = "s6-rc";
version = "0.5.6.0";
sha256 = "sha256-gSd/aAXo2ZmtKVv5FAqQmUO2h//Ptao8Tv2EsaV0WG4=";
manpages = skawarePackages.buildManPages {
pname = "s6-rc-man-pages";
version = "0.5.5.0.1";
sha256 = "sha256-Ywke3FG/xhhUd934auDB+iFRDCvy8IJs6IkirP6O/As=";
description = "mdoc(7) versions of the documentation for the s6-rc service manager";
maintainers = [ lib.maintainers.qyliss ];
};
description = "Service manager for s6-based systems";
platforms = lib.platforms.unix;
outputs = [
"bin"
"lib"
"dev"
"doc"
"out"
];
configureFlags = [
"--libdir=\${lib}/lib"
"--libexecdir=\${lib}/libexec"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-include=${execline.dev}/include"
"--with-include=${s6.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-lib=${execline.lib}/lib"
"--with-lib=${s6.out}/lib"
"--with-dynlib=${skalibs.lib}/lib"
"--with-dynlib=${execline.lib}/lib"
"--with-dynlib=${s6.out}/lib"
];
# s6-rc-compile generates built-in service definitions containing
# absolute paths to execline, s6, and s6-rc programs. If we're
# running s6-rc-compile as part of a Nix derivation, and we want to
# cross-compile that derivation, those paths will be wrong --
# they'll be for execline, s6, and s6-rc on the platform we're
# running s6-rc-compile on, not the platform we're targeting.
#
# We can detect this special case of s6-rc being used at build time
# in a derivation that's being cross-compiled, because that's the
# only time hostPlatform != targetPlatform. When that happens we
# modify s6-rc-compile to use the configuration headers for the
# system we're cross-compiling for.
postConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
substituteInPlace src/s6-rc/s6-rc-compile.c \
--replace-fail '<execline/config.h>' '"${targetPackages.execline.dev}/include/execline/config.h"' \
--replace-fail '<s6/config.h>' '"${targetPackages.s6.dev}/include/s6/config.h"' \
--replace-fail '<s6-rc/config.h>' '"${targetPackages.s6-rc.dev}/include/s6-rc/config.h"'
'';
postInstall = ''
# remove all s6 executables from build directory
rm $(find -name "s6-rc-*" -type f -mindepth 1 -maxdepth 1 -executable)
rm s6-rc libs6rc.*
mv doc $doc/share/doc/s6-rc/html
mv examples $doc/share/doc/s6-rc/examples
'';
}

View File

@@ -0,0 +1,59 @@
{
lib,
skawarePackages,
skalibs,
execline,
}:
skawarePackages.buildPackage {
pname = "s6";
version = "2.13.2.0";
sha256 = "sha256-xRFLgEJxa7cGkUBpMayw4nltg7Qcv7XIBo3OegL5mkU=";
manpages = skawarePackages.buildManPages {
pname = "s6-man-pages";
version = "2.13.1.0.1";
sha256 = "sha256-SChxod/W/KxxSic4ttXigwgRWMWLl9Z66i2t7H1nn/s=";
description = "Port of the documentation for the s6 supervision suite to mdoc";
maintainers = [ lib.maintainers.sternenseemann ];
};
description = "skarnet.org's small & secure supervision software suite";
# NOTE lib: cannot split lib from bin at the moment,
# since some parts of lib depend on executables in bin.
# (the `*_startf` functions in `libs6`)
outputs = [
# "bin" "lib"
"out"
"dev"
"doc"
];
# TODO: nsss support
configureFlags = [
"--libdir=\${out}/lib"
"--libexecdir=\${out}/libexec"
"--dynlibdir=\${out}/lib"
"--bindir=\${out}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-include=${execline.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-lib=${execline.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
"--with-dynlib=${execline.lib}/lib"
];
postInstall = ''
# remove all s6 executables from build directory
rm $(find -type f -mindepth 1 -maxdepth 1 -executable)
rm libs6.*
rm ./libs6auto.a.xyzzy
mv doc $doc/share/doc/s6/html
mv examples $doc/share/doc/s6/examples
'';
}

View File

@@ -0,0 +1,47 @@
{
lib,
runCommandCC,
skalibs,
}:
let
# From https://skarnet.org/software/misc/sdnotify-wrapper.c,
# which is unversioned.
src = ./sdnotify-wrapper.c;
in
runCommandCC "sdnotify-wrapper"
{
outputs = [
"bin"
"doc"
"out"
];
meta = {
homepage = "https://skarnet.org/software/misc/sdnotify-wrapper.c";
description = "Use systemd sd_notify without having to link against libsystemd";
mainProgram = "sdnotify-wrapper";
platforms = lib.platforms.linux;
license = lib.licenses.isc;
maintainers = with lib.maintainers; [ Profpatsch ];
};
}
''
mkdir -p $bin/bin
mkdir $out
# the -lskarnet has to come at the end to support static builds
$CC \
-o $bin/bin/sdnotify-wrapper \
-I${skalibs.dev}/include \
-L${skalibs.lib}/lib \
${src} \
-lskarnet
mkdir -p $doc/share/doc/sdnotify-wrapper
# copy the documentation comment
sed -ne '/Usage:/,/*\//p' ${src} > $doc/share/doc/sdnotify-wrapper/README
''

View File

@@ -0,0 +1,174 @@
/*
Copyright: (C)2015-2020 Laurent Bercot. http://skarnet.org/
ISC license. See http://opensource.org/licenses/ISC
Build-time requirements: skalibs. https://skarnet.org/software/skalibs/
Run-time requirements: none, if you link skalibs statically.
Compilation:
gcc -o sdnotify-wrapper -L/usr/lib/skalibs sdnotify-wrapper.c -lskarnet
Use /usr/lib/skalibs/libskarnet.a instead of -lskarnet to link statically.
Adapt gcc's -I and -L options to your skalibs installation paths.
Usage: if a daemon would be launched by systemd as "foobard args...",
launch it as "sdnotify-wrapper foobard args..." instead, and you can now
tell systemd that this daemon supports readiness notification.
Instead of using sd_notify() and having to link against the systemd
library, the daemon notifies readiness by writing whatever it wants
to a file descriptor (by default: stdout), then a newline. (Then it
should close that file descriptor.) The simplest way is something like
int notify_readiness() { write(1, "\n", 1) ; close(1) ; }
This mechanism is understandable by any notification readiness framework.
Readiness notification occurs when the newline is written, not when
the descriptor is closed; but since sdnotify-wrapper stops reading
after the first newline and will exit, any subsequent writes will
fail and it's best to simply close the descriptor right away.
sdnotify-wrapper sees the notification when it occurs and sends it
to systemd using the sd_notify format.
Options:
-d fd: the daemon will write its notification on descriptor fd.
Default is 1.
-f: do not doublefork. Use if the daemon waits for children it does
not know it has (for instance, superservers do this). When in doubt,
do not use that option, or you may have a zombie hanging around.
-t timeout: if the daemon has not sent a notification after timeout
milliseconds, give up and exit; systemd will not be notified.
-k: keep the NOTIFY_SOCKET environment variable when execing into the
daemon. By default, the variable is unset: the daemon should not need it.
Notes:
sdnotify-wrapper does not change the daemon's pid. It runs as a
(grand)child of the daemon.
If the NOTIFY_SOCKET environment variable is not set, sdnotify-wrapper
does nothing - it only execs into the daemon.
sdnotify-wrapper is more liberal than sd_notify(). It will accept
a relative path in NOTIFY_SOCKET.
*/
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <skalibs/uint64.h>
#include <skalibs/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/tai.h>
#include <skalibs/iopause.h>
#include <skalibs/djbunix.h>
#include <skalibs/socket.h>
#include <skalibs/exec.h>
#define USAGE "sdnotify-wrapper [ -d fd ] [ -f ] [ -t timeout ] [ -k ] prog..."
#define dieusage() strerr_dieusage(100, USAGE)
#define VAR "NOTIFY_SOCKET"
static inline int ipc_sendto (int fd, char const *s, size_t len, char const *path)
{
struct sockaddr_un sa ;
size_t l = strlen(path) ;
if (l > IPCPATH_MAX) return (errno = ENAMETOOLONG, 0) ;
memset(&sa, 0, sizeof sa) ;
sa.sun_family = AF_UNIX ;
memcpy(sa.sun_path, path, l+1) ;
if (path[0] == '@') sa.sun_path[0] = 0 ;
return sendto(fd, s, len, MSG_NOSIGNAL, (struct sockaddr *)&sa, sizeof sa) >= 0 ;
}
static inline void notify_systemd (pid_t pid, char const *socketpath)
{
size_t n = 16 ;
char fmt[16 + PID_FMT] = "READY=1\nMAINPID=" ;
int fd = ipc_datagram_b() ;
if (fd < 0) strerr_diefu1sys(111, "create socket") ;
n += pid_fmt(fmt + n, pid) ;
fmt[n++] = '\n' ;
if (!ipc_sendto(fd, fmt, n, socketpath))
strerr_diefu2sys(111, "send notification message to ", socketpath) ;
close(fd) ;
}
static inline int run_child (int fd, unsigned int timeout, pid_t pid, char const *s)
{
char dummy[4096] ;
iopause_fd x = { .fd = fd, .events = IOPAUSE_READ } ;
tain deadline ;
tain_now_g() ;
if (timeout) tain_from_millisecs(&deadline, timeout) ;
else deadline = tain_infinite_relative ;
tain_add_g(&deadline, &deadline) ;
for (;;)
{
int r = iopause_g(&x, 1, &deadline) ;
if (r < 0) strerr_diefu1sys(111, "iopause") ;
if (!r) return 99 ;
r = sanitize_read(fd_read(fd, dummy, 4096)) ;
if (r < 0)
if (errno == EPIPE) return 1 ;
else strerr_diefu1sys(111, "read from parent") ;
else if (r && memchr(dummy, '\n', r)) break ;
}
close(fd) ;
notify_systemd(pid, s) ;
return 0 ;
}
int main (int argc, char const *const *argv)
{
char const *s = getenv(VAR) ;
unsigned int fd = 1 ;
unsigned int timeout = 0 ;
int df = 1, keep = 0 ;
PROG = "sdnotify-wrapper" ;
{
subgetopt l = SUBGETOPT_ZERO ;
for (;;)
{
int opt = subgetopt_r(argc, argv, "d:ft:k", &l) ;
if (opt == -1) break ;
switch (opt)
{
case 'd' : if (!uint0_scan(l.arg, &fd)) dieusage() ; break ;
case 'f' : df = 0 ; break ;
case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
case 'k' : keep = 1 ; break ;
default : dieusage() ;
}
}
argc -= l.ind ; argv += l.ind ;
}
if (!argc) dieusage() ;
if (!s) xexec(argv) ;
else
{
pid_t parent = getpid() ;
pid_t child ;
int p[2] ;
if (pipe(p) < 0) strerr_diefu1sys(111, "pipe") ;
child = df ? doublefork() : fork() ;
if (child < 0) strerr_diefu1sys(111, df ? "doublefork" : "fork") ;
else if (!child)
{
PROG = "sdnotify-wrapper (child)" ;
close(p[1]) ;
return run_child(p[0], timeout, parent, s) ;
}
close(p[0]) ;
if (fd_move((int)fd, p[1]) < 0) strerr_diefu1sys(111, "move descriptor") ;
if (keep) xexec(argv) ;
else xmexec_m(argv, VAR, sizeof(VAR)) ;
}
}

View File

@@ -0,0 +1,36 @@
{ skawarePackages }:
skawarePackages.buildPackage {
pname = "skalibs";
version = "2.10.0.3";
sha256 = "0ka6n5rnxd5sn5lycarf596d5wlak5s535zqqlz0rnhdcnpb105p";
description = "Set of general-purpose C programming libraries";
outputs = [
"lib"
"dev"
"doc"
"out"
];
configureFlags = [
# assume /dev/random works
"--enable-force-devr"
"--libdir=\${lib}/lib"
"--dynlibdir=\${lib}/lib"
"--includedir=\${dev}/include"
"--sysdepdir=\${lib}/lib/skalibs/sysdeps"
# Empty the default path, which would be "/usr/bin:bin".
# It would be set when PATH is empty. This hurts hermeticity.
"--with-default-path="
];
postInstall = ''
rm -rf sysdeps.cfg
rm libskarnet.*
mv doc $doc/share/doc/skalibs/html
'';
}

View File

@@ -0,0 +1,68 @@
{
lib,
stdenv,
skawarePackages,
pkgs,
}:
skawarePackages.buildPackage {
pname = "skalibs";
version = "2.14.4.0";
sha256 = "sha256-DmJiYYSMySBzj5L9UKJMFLIeMDBt/tl7hDU2n0uuAKU=";
description = "Set of general-purpose C programming libraries";
outputs = [
"lib"
"dev"
"doc"
"out"
];
configureFlags = [
# assume /dev/random works
"--enable-force-devr"
"--libdir=\${lib}/lib"
"--dynlibdir=\${lib}/lib"
"--includedir=\${dev}/include"
"--sysdepdir=\${lib}/lib/skalibs/sysdeps"
# Empty the default path, which would be "/usr/bin:bin".
# It would be set when PATH is empty. This hurts hermeticity.
"--with-default-path="
]
++ lib.optionals (stdenv.buildPlatform.config != stdenv.hostPlatform.config) [
# There's a fallback path for BSDs.
"--with-sysdep-procselfexe=${
if stdenv.hostPlatform.isLinux then
"/proc/self/exe"
else if stdenv.hostPlatform.isSunOS then
"/proc/self/path/a.out"
else
"none"
}"
# ./configure: sysdep posixspawnearlyreturn cannot be autodetected
# when cross-compiling. Please manually provide a value with the
# --with-sysdep-posixspawnearlyreturn=yes|no|... option.
#
# posixspawnearlyreturn: `yes` if the target has a broken
# `posix_spawn()` implementation that can return before the
# child has successfully exec'ed. That happens with old glibcs
# and some virtual platforms.
"--with-sysdep-posixspawnearlyreturn=no"
];
postInstall = ''
rm -rf sysdeps.cfg
rm libskarnet.*
mv doc $doc/share/doc/skalibs/html
'';
passthru.tests = {
# fdtools is one of the few non-skalib packages that depends on skalibs
# and might break if skalibs gets an breaking update.
fdtools = pkgs.fdtools;
};
}

View File

@@ -0,0 +1,49 @@
{
skawarePackages,
stdenv,
skalibs,
}:
skawarePackages.buildPackage {
pname = "tipidee";
version = "0.0.6.0";
sha256 = "sha256-4q3YvhCJAi43kCQbk6xKWj5Y2tZF9dkZ+MunRM1KFwI=";
description = "HTTP 1.1 webserver, serving static files and CGI/NPH";
outputs = [
"bin"
"lib"
"out"
"dev"
"doc"
];
configureFlags = [
"--libdir=\${lib}/lib"
"--libexecdir=\${lib}/libexec"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
# we set sysconfdir to /etc here to allow tipidee-config
# to look in the global paths for its configs.
# This is not encouraged, but a valid use-case.
"--sysconfdir=/etc"
];
postInstall = ''
# remove all tipidee executables from build directory
rm $(find -type f -mindepth 1 -maxdepth 1 -executable)
rm libtipidee.*
mv doc $doc/share/doc/tipidee/html
mv examples $doc/share/doc/tipidee/examples
'';
broken = stdenv.hostPlatform.isDarwin;
}

View File

@@ -0,0 +1,29 @@
{ skawarePackages, skalibs }:
skawarePackages.buildPackage {
pname = "utmps";
version = "0.1.3.1";
sha256 = "sha256-HEwTerNm9txrgdOlcsmXUUtk14S9Uuf5UU5vbz8chbk=";
description = "Secure utmpx and wtmp implementation";
configureFlags = [
"--libdir=\${lib}/lib"
"--dynlibdir=\${lib}/lib"
"--bindir=\${bin}/bin"
"--includedir=\${dev}/include"
"--with-sysdeps=${skalibs.lib}/lib/skalibs/sysdeps"
"--with-include=${skalibs.dev}/include"
"--with-lib=${skalibs.lib}/lib"
"--with-dynlib=${skalibs.lib}/lib"
];
postInstall = ''
# remove all execline executables from build directory
rm $(find -type f -mindepth 1 -maxdepth 1 -executable)
rm libutmps.*
mv doc $doc/share/doc/utmps/html
mv examples $doc/share/doc/utmps/examples
'';
}