From a76bd5509036cad8af42c534757085dbbd254d6f Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 28 Oct 2022 01:13:45 -0300 Subject: skawarePackages: move all of them to development/skaware-packages --- .../skaware-packages/build-skaware-man-pages.nix | 45 ++++++ .../skaware-packages/build-skaware-package.nix | 117 ++++++++++++++ .../skaware-packages/clean-packaging.nix | 53 +++++++ .../execline-man-pages/default.nix | 9 ++ .../skaware-packages/execline/default.nix | 68 ++++++++ .../skaware-packages/execline/execlineb-wrapper.c | 51 ++++++ .../development/skaware-packages/mdevd/default.nix | 28 ++++ pkgs/development/skaware-packages/nsss/default.nix | 33 ++++ .../skaware-packages/s6-dns/default.nix | 36 +++++ .../skaware-packages/s6-linux-init/default.nix | 39 +++++ .../skaware-packages/s6-linux-utils/default.nix | 32 ++++ .../skaware-packages/s6-man-pages/default.nix | 9 ++ .../s6-networking-man-pages/default.nix | 9 ++ .../skaware-packages/s6-networking/default.nix | 65 ++++++++ .../s6-portable-utils-man-pages/default.nix | 9 ++ .../skaware-packages/s6-portable-utils/default.nix | 32 ++++ .../development/skaware-packages/s6-rc/default.nix | 61 ++++++++ pkgs/development/skaware-packages/s6/default.nix | 43 +++++ .../skaware-packages/sdnotify-wrapper/default.nix | 37 +++++ .../sdnotify-wrapper/sdnotify-wrapper.c | 174 +++++++++++++++++++++ pkgs/development/skaware-packages/skalibs/2_10.nix | 31 ++++ .../skaware-packages/skalibs/default.nix | 39 +++++ .../development/skaware-packages/utmps/default.nix | 31 ++++ 23 files changed, 1051 insertions(+) create mode 100644 pkgs/development/skaware-packages/build-skaware-man-pages.nix create mode 100644 pkgs/development/skaware-packages/build-skaware-package.nix create mode 100644 pkgs/development/skaware-packages/clean-packaging.nix create mode 100644 pkgs/development/skaware-packages/execline-man-pages/default.nix create mode 100644 pkgs/development/skaware-packages/execline/default.nix create mode 100644 pkgs/development/skaware-packages/execline/execlineb-wrapper.c create mode 100644 pkgs/development/skaware-packages/mdevd/default.nix create mode 100644 pkgs/development/skaware-packages/nsss/default.nix create mode 100644 pkgs/development/skaware-packages/s6-dns/default.nix create mode 100644 pkgs/development/skaware-packages/s6-linux-init/default.nix create mode 100644 pkgs/development/skaware-packages/s6-linux-utils/default.nix create mode 100644 pkgs/development/skaware-packages/s6-man-pages/default.nix create mode 100644 pkgs/development/skaware-packages/s6-networking-man-pages/default.nix create mode 100644 pkgs/development/skaware-packages/s6-networking/default.nix create mode 100644 pkgs/development/skaware-packages/s6-portable-utils-man-pages/default.nix create mode 100644 pkgs/development/skaware-packages/s6-portable-utils/default.nix create mode 100644 pkgs/development/skaware-packages/s6-rc/default.nix create mode 100644 pkgs/development/skaware-packages/s6/default.nix create mode 100644 pkgs/development/skaware-packages/sdnotify-wrapper/default.nix create mode 100644 pkgs/development/skaware-packages/sdnotify-wrapper/sdnotify-wrapper.c create mode 100644 pkgs/development/skaware-packages/skalibs/2_10.nix create mode 100644 pkgs/development/skaware-packages/skalibs/default.nix create mode 100644 pkgs/development/skaware-packages/utmps/default.nix (limited to 'pkgs/development/skaware-packages') diff --git a/pkgs/development/skaware-packages/build-skaware-man-pages.nix b/pkgs/development/skaware-packages/build-skaware-man-pages.nix new file mode 100644 index 0000000000000..92d8202ae95a8 --- /dev/null +++ b/pkgs/development/skaware-packages/build-skaware-man-pages.nix @@ -0,0 +1,45 @@ +{ lib, stdenv, fetchFromGitHub }: + +{ + # : 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 = fetchFromGitHub { + inherit owner rev sha256; + repo = pname; + }; +in + +stdenv.mkDerivation { + inherit pname version src; + + makeFlags = [ + "MANPATH=${manDir}" + ]; + + dontBuild = true; + + meta = with lib; { + inherit description license maintainers; + inherit (src.meta) homepage; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/skaware-packages/build-skaware-package.nix b/pkgs/development/skaware-packages/build-skaware-package.nix new file mode 100644 index 0000000000000..3ae9b7ce8aac2 --- /dev/null +++ b/pkgs/development/skaware-packages/build-skaware-package.nix @@ -0,0 +1,117 @@ +{ lib, stdenv, cleanPackaging, fetchurl }: +{ + # : string + pname + # : string +, version + # : string +, sha256 + # : 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 ? { } + +}: + +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; + }; + + inherit outputs; + + 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.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.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} + + ${postInstall} + ''; + + postFixup = '' + ${cleanPackaging.checkForRemainingFiles} + ''; + + meta = { + homepage = "https://skarnet.org/software/${pname}/"; + inherit description platforms; + license = lib.licenses.isc; + maintainers = with lib.maintainers; + [ pmahoney Profpatsch qyliss ] ++ maintainers; + }; + + inherit passthru; + +} diff --git a/pkgs/development/skaware-packages/clean-packaging.nix b/pkgs/development/skaware-packages/clean-packaging.nix new file mode 100644 index 0000000000000..d51cbec8aeb26 --- /dev/null +++ b/pkgs/development/skaware-packages/clean-packaging.nix @@ -0,0 +1,53 @@ +# 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; +} diff --git a/pkgs/development/skaware-packages/execline-man-pages/default.nix b/pkgs/development/skaware-packages/execline-man-pages/default.nix new file mode 100644 index 0000000000000..822bbea1aee51 --- /dev/null +++ b/pkgs/development/skaware-packages/execline-man-pages/default.nix @@ -0,0 +1,9 @@ +{ lib, buildManPages }: + +buildManPages { + pname = "execline-man-pages"; + version = "2.9.0.0.1"; + sha256 = "sha256-hT0YsuYJ3XSMYwtlwDR8PGlD8ng8XPky93rCprruHu8="; + description = "Port of the documentation for the execline suite to mdoc"; + maintainers = [ lib.maintainers.sternenseemann ]; +} diff --git a/pkgs/development/skaware-packages/execline/default.nix b/pkgs/development/skaware-packages/execline/default.nix new file mode 100644 index 0000000000000..953a081051677 --- /dev/null +++ b/pkgs/development/skaware-packages/execline/default.nix @@ -0,0 +1,68 @@ +{ fetchFromGitHub, skawarePackages }: + +with skawarePackages; +let + version = "2.9.0.1"; + + # 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 = fetchFromGitHub { + owner = "flexibeast"; + repo = "execline-man-pages"; + rev = "v2.9.0.0.1"; + sha256 = "sha256-hT0YsuYJ3XSMYwtlwDR8PGlD8ng8XPky93rCprruHu8="; + }; + +in buildPackage { + inherit version; + + pname = "execline"; + sha256 = "sha256-ASYPyvgP+8oqlKpV6kdN+545swM7VciviBJnkYeVMfY="; + + description = "A small scripting language, to be used in place of a shell in non-interactive scripts"; + + outputs = [ "bin" "man" "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 + mkdir -p $man/share/ + cp -vr ${manpages}/man* $man/share + ''; +} diff --git a/pkgs/development/skaware-packages/execline/execlineb-wrapper.c b/pkgs/development/skaware-packages/execline/execlineb-wrapper.c new file mode 100644 index 0000000000000..c8e91813b7744 --- /dev/null +++ b/pkgs/development/skaware-packages/execline/execlineb-wrapper.c @@ -0,0 +1,51 @@ +/* + * A wrapper around execlineb, which provides all execline + * tools on execlineb’s PATH. + * It is implemented as a C program, because on non-Linux, + * nested shebang lines are not supported. + */ + +#include +#include + +#include +#include +#include +#include +#include + +#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 + ); +} diff --git a/pkgs/development/skaware-packages/mdevd/default.nix b/pkgs/development/skaware-packages/mdevd/default.nix new file mode 100644 index 0000000000000..2a55676fc7675 --- /dev/null +++ b/pkgs/development/skaware-packages/mdevd/default.nix @@ -0,0 +1,28 @@ +{ lib, skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "mdevd"; + version = "0.1.5.2"; + sha256 = "sha256-RgNys9O6yfNXQVbtfkhhj59KNhy1LESUrZBjJIq0pP8="; + + 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) + + mv doc $doc/share/doc/mdevd/html + mv examples $doc/share/doc/mdevd/examples + ''; +} diff --git a/pkgs/development/skaware-packages/nsss/default.nix b/pkgs/development/skaware-packages/nsss/default.nix new file mode 100644 index 0000000000000..e6db2aee60c54 --- /dev/null +++ b/pkgs/development/skaware-packages/nsss/default.nix @@ -0,0 +1,33 @@ +{ skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "nsss"; + version = "0.2.0.1"; + sha256 = "0nqjnfqvzzn4i45h849b3n8qwcrzd5wlrwlvkmjdga5k4yk4x63x"; + + description = "An 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 + ''; + +} diff --git a/pkgs/development/skaware-packages/s6-dns/default.nix b/pkgs/development/skaware-packages/s6-dns/default.nix new file mode 100644 index 0000000000000..3c1e984f86c5e --- /dev/null +++ b/pkgs/development/skaware-packages/s6-dns/default.nix @@ -0,0 +1,36 @@ +{ skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "s6-dns"; + version = "2.3.5.4"; + sha256 = "sha256-dq8iJHLEdU+DzcWa01QlXOGx5vaDOgWTKEY/jlH020M="; + + description = "A 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.* + rm libdcache.* + + mv doc $doc/share/doc/s6-dns/html + ''; + +} diff --git a/pkgs/development/skaware-packages/s6-linux-init/default.nix b/pkgs/development/skaware-packages/s6-linux-init/default.nix new file mode 100644 index 0000000000000..27773a90e2834 --- /dev/null +++ b/pkgs/development/skaware-packages/s6-linux-init/default.nix @@ -0,0 +1,39 @@ +{ lib, skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "s6-linux-init"; + version = "1.0.8.0"; + sha256 = "sha256-kgVaeWTPZmBAZq2WSiwjku58XmSCG+AxRsE0Hg2MPcY="; + + description = "A 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" + ]; + + 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 + ''; + +} diff --git a/pkgs/development/skaware-packages/s6-linux-utils/default.nix b/pkgs/development/skaware-packages/s6-linux-utils/default.nix new file mode 100644 index 0000000000000..98199516a04e4 --- /dev/null +++ b/pkgs/development/skaware-packages/s6-linux-utils/default.nix @@ -0,0 +1,32 @@ +{ lib, skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "s6-linux-utils"; + version = "2.6.0.0"; + sha256 = "sha256-bHEyc0oMgocALuaRDEafF1qX12aoAjwMM6+LqSZD7Vk="; + + description = "A 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 + + mv doc $doc/share/doc/s6-linux-utils/html + ''; + +} diff --git a/pkgs/development/skaware-packages/s6-man-pages/default.nix b/pkgs/development/skaware-packages/s6-man-pages/default.nix new file mode 100644 index 0000000000000..44430eacbe08a --- /dev/null +++ b/pkgs/development/skaware-packages/s6-man-pages/default.nix @@ -0,0 +1,9 @@ +{ lib, buildManPages }: + +buildManPages { + pname = "s6-man-pages"; + version = "2.11.1.1.1"; + sha256 = "sha256-W1+f65+Su1ZjCtzstn/fqWyU9IlQMThd/1lOg1cbCaE="; + description = "Port of the documentation for the s6 supervision suite to mdoc"; + maintainers = [ lib.maintainers.sternenseemann ]; +} diff --git a/pkgs/development/skaware-packages/s6-networking-man-pages/default.nix b/pkgs/development/skaware-packages/s6-networking-man-pages/default.nix new file mode 100644 index 0000000000000..99dc9b891f57d --- /dev/null +++ b/pkgs/development/skaware-packages/s6-networking-man-pages/default.nix @@ -0,0 +1,9 @@ +{ lib, buildManPages }: + +buildManPages { + pname = "s6-networking-man-pages"; + version = "2.5.1.1.1"; + sha256 = "sha256-RGXOSCsl1zfiXf5pIgsex/6LWtKh7ne0R7rqHvnQB8E="; + description = "Port of the documentation for the s6-networking suite to mdoc"; + maintainers = [ lib.maintainers.sternenseemann ]; +} diff --git a/pkgs/development/skaware-packages/s6-networking/default.nix b/pkgs/development/skaware-packages/s6-networking/default.nix new file mode 100644 index 0000000000000..6eae406fa22a5 --- /dev/null +++ b/pkgs/development/skaware-packages/s6-networking/default.nix @@ -0,0 +1,65 @@ +{ lib, skawarePackages + +# Whether to build the TLS/SSL tools and what library to use +# acceptable values: "bearssl", "libressl", false +, sslSupport ? "bearssl" , libressl, bearssl +}: + +with skawarePackages; +let + sslSupportEnabled = sslSupport != false; + sslLibs = { + libressl = libressl; + bearssl = bearssl; + }; + +in +assert sslSupportEnabled -> sslLibs ? ${sslSupport}; + + +buildPackage { + pname = "s6-networking"; + version = "2.5.1.1"; + sha256 = "sha256-esedTePZwTUy5ESrdJfE4ErQ+nIp1QKYTZ3H1IqmRBg="; + + description = "A 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 + ''; + +} diff --git a/pkgs/development/skaware-packages/s6-portable-utils-man-pages/default.nix b/pkgs/development/skaware-packages/s6-portable-utils-man-pages/default.nix new file mode 100644 index 0000000000000..6380071d7629e --- /dev/null +++ b/pkgs/development/skaware-packages/s6-portable-utils-man-pages/default.nix @@ -0,0 +1,9 @@ +{ lib, buildManPages }: + +buildManPages { + pname = "s6-portable-utils-man-pages"; + version = "2.2.5.0.1"; + sha256 = "sha256-pIh+PKqKJTkaHyYrbWEEzdGDSzEO9E+ekTovu4SVSs4="; + description = "Port of the documentation for the s6-portable-utils suite to mdoc"; + maintainers = [ lib.maintainers.somasis ]; +} diff --git a/pkgs/development/skaware-packages/s6-portable-utils/default.nix b/pkgs/development/skaware-packages/s6-portable-utils/default.nix new file mode 100644 index 0000000000000..490a38e1031bb --- /dev/null +++ b/pkgs/development/skaware-packages/s6-portable-utils/default.nix @@ -0,0 +1,32 @@ +{ skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "s6-portable-utils"; + version = "2.2.5.0"; + sha256 = "sha256-67OfiTT9NvJdMTUuYbvZTcArHp8EQRhQ0v2WWL2RbjY="; + + description = "A 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 + ''; + + +} diff --git a/pkgs/development/skaware-packages/s6-rc/default.nix b/pkgs/development/skaware-packages/s6-rc/default.nix new file mode 100644 index 0000000000000..0f2662fd72405 --- /dev/null +++ b/pkgs/development/skaware-packages/s6-rc/default.nix @@ -0,0 +1,61 @@ +{ lib, stdenv, skawarePackages, targetPackages }: + +with skawarePackages; + +buildPackage { + pname = "s6-rc"; + version = "0.5.3.2"; + sha256 = "sha256-TySklmpKo1PSvRqK/Km4jHt70pxGs6Gn9TBWhrnW4Dg="; + + description = "A 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 '' '"${targetPackages.execline.dev}/include/execline/config.h"' \ + --replace '' '"${targetPackages.s6.dev}/include/s6/config.h"' \ + --replace '' '"${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 + ''; + +} diff --git a/pkgs/development/skaware-packages/s6/default.nix b/pkgs/development/skaware-packages/s6/default.nix new file mode 100644 index 0000000000000..1c3795a3f6afe --- /dev/null +++ b/pkgs/development/skaware-packages/s6/default.nix @@ -0,0 +1,43 @@ +{ skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "s6"; + version = "2.11.1.2"; + sha256 = "sha256-bBR0vj6Inaw5LO4wer4BXNS+DIXHJchOp/GE8ONFA6I="; + + 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 ./libs6lockd.a.xyzzy + + mv doc $doc/share/doc/s6/html + mv examples $doc/share/doc/s6/examples + ''; + +} diff --git a/pkgs/development/skaware-packages/sdnotify-wrapper/default.nix b/pkgs/development/skaware-packages/sdnotify-wrapper/default.nix new file mode 100644 index 0000000000000..b4b6a7f42a7e4 --- /dev/null +++ b/pkgs/development/skaware-packages/sdnotify-wrapper/default.nix @@ -0,0 +1,37 @@ +{ stdenv, lib, runCommandCC, skawarePackages }: + +with skawarePackages; + +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"; + 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 +'' diff --git a/pkgs/development/skaware-packages/sdnotify-wrapper/sdnotify-wrapper.c b/pkgs/development/skaware-packages/sdnotify-wrapper/sdnotify-wrapper.c new file mode 100644 index 0000000000000..3ad3cbc690639 --- /dev/null +++ b/pkgs/development/skaware-packages/sdnotify-wrapper/sdnotify-wrapper.c @@ -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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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)) ; + } +} diff --git a/pkgs/development/skaware-packages/skalibs/2_10.nix b/pkgs/development/skaware-packages/skalibs/2_10.nix new file mode 100644 index 0000000000000..af4c04dab1e7f --- /dev/null +++ b/pkgs/development/skaware-packages/skalibs/2_10.nix @@ -0,0 +1,31 @@ +{ skawarePackages }: + +skawarePackages.buildPackage { + pname = "skalibs"; + version = "2.10.0.3"; + sha256 = "0ka6n5rnxd5sn5lycarf596d5wlak5s535zqqlz0rnhdcnpb105p"; + + description = "A 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 + ''; + +} diff --git a/pkgs/development/skaware-packages/skalibs/default.nix b/pkgs/development/skaware-packages/skalibs/default.nix new file mode 100644 index 0000000000000..19c8ea98ec917 --- /dev/null +++ b/pkgs/development/skaware-packages/skalibs/default.nix @@ -0,0 +1,39 @@ +{ skawarePackages, pkgs }: + +with skawarePackages; + +buildPackage { + pname = "skalibs"; + version = "2.12.0.1"; + sha256 = "sha256-PiKPcvGNiMF/bE4KZogdbTd5Qnt+foifMUK28m2jAoU="; + + description = "A 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 + ''; + + 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; + }; + +} diff --git a/pkgs/development/skaware-packages/utmps/default.nix b/pkgs/development/skaware-packages/utmps/default.nix new file mode 100644 index 0000000000000..a7063f198c508 --- /dev/null +++ b/pkgs/development/skaware-packages/utmps/default.nix @@ -0,0 +1,31 @@ +{ skawarePackages }: + +with skawarePackages; + +buildPackage { + pname = "utmps"; + version = "0.1.2.0"; + sha256 = "sha256-kCXZYbgnGg7MjutXhhJra3mTdq+m8r0lwPhy/STxEjw="; + + description = "A 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 + ''; +} -- cgit 1.4.1