diff --git a/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff b/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff new file mode 100644 index 000000000000..0bf0a9bd6177 --- /dev/null +++ b/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff @@ -0,0 +1,45 @@ +diff -Naur cron-old/externs.h cron-new/externs.h +--- cron-old/externs.h 2024-08-23 09:04:25.525752797 -0300 ++++ cron-new/externs.h 2024-08-23 10:12:05.304311078 -0300 +@@ -121,3 +121,14 @@ + #ifndef WCOREDUMP + # define WCOREDUMP(st) (((st) & 0200) != 0) + #endif ++ ++/* Nixpkgs-specific patch begin */ ++ ++/* ++ Implicit saved UIDs do not work here due to way NixOS uses setuid wrappers ++ See https://github.com/NixOS/nixpkgs/issues/16518 ++ */ ++ ++#undef HAVE_SAVED_UIDS ++ ++/* Nixpkgs-specific patch end */ +diff -Naur cron-old/pathnames.h cron-new/pathnames.h +--- cron-old/pathnames.h 2024-08-23 09:04:25.524752791 -0300 ++++ cron-new/pathnames.h 2024-08-23 10:11:33.186749198 -0300 +@@ -105,4 +105,23 @@ + # define _PATH_DEVNULL "/dev/null" + #endif + ++/* Nixpkgs-specific patch begin */ ++ ++/* ++ We want to ignore the $glibc/include/paths.h definition of sendmail path. ++ Further, set a usable default PATH ++ See https://github.com/NixOS/nixpkgs/issues/16518 ++ */ ++ ++#undef _PATH_SENDMAIL ++#define _PATH_SENDMAIL "@sendmailPath@" ++ ++#undef _PATH_VI ++#define _PATH_VI "@VIPATH@" ++ ++#undef _PATH_DEFPATH ++#define _PATH_DEFPATH "@DEFPATH@" ++ ++/* Nixpkgs-specific patch end */ ++ + #endif /* _PATHNAMES_H_ */ diff --git a/pkgs/by-name/is/isc-cron/package.nix b/pkgs/by-name/is/isc-cron/package.nix index 8f8421781e36..b52086fca473 100644 --- a/pkgs/by-name/is/isc-cron/package.nix +++ b/pkgs/by-name/is/isc-cron/package.nix @@ -1,49 +1,71 @@ -{lib, stdenv, fetchurl, vim, sendmailPath ? "/usr/sbin/sendmail"}: +{ + lib, + fetchurl, + stdenv, + substituteAll, + vim, + sendmailPath ? "/usr/sbin/sendmail", +}: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "cron"; version = "4.1"; src = fetchurl { - url = "ftp://ftp.isc.org/isc/cron/cron_${version}.shar"; - sha256 = "16n3dras4b1jh7g958nz1k54pl9pg5fwb3fvjln8z67varvq6if4"; + url = "ftp://ftp.isc.org/isc/cron/cron_${finalAttrs.version}.shar"; + hash = "sha256-xEWDd1b7mI8slduNxV15N9FLygzfopLegTIsolVuw5o="; }; - unpackCmd = "(mkdir cron && cd cron && sh $curSrc)"; + patches = [ + (substituteAll { + src = ./0000-nixpkgs-specific.diff; + inherit sendmailPath; + VIPATH = lib.getExe' vim "vim"; + DEFPATH = lib.concatStringsSep ":" [ + "/run/wrappers/bin" + "/nix/var/nix/profiles/default/bin" + "/run/current-system/sw/bin" + "/usr/bin" + "/bin" + ]; + }) + ]; + + makeFlags = [ + "CC=${stdenv.cc.targetPrefix}cc" + "DESTROOT=$(out)" + ]; hardeningEnable = [ "pie" ]; - preBuild = '' - # do not set sticky bit in /nix/store - substituteInPlace Makefile --replace ' -o root' ' ' --replace 111 755 --replace 4755 0755 - # do not strip during install, broken on cross and we'll do ourselves as needed - substituteInPlace Makefile --replace ' -s cron' ' cron' - makeFlags="DESTROOT=$out CC=$CC" - - # We want to ignore the $glibc/include/paths.h definition of - # sendmail path. - # Also set a usable default PATH (#16518). - cat >> pathnames.h <<__EOT__ - #undef _PATH_SENDMAIL - #define _PATH_SENDMAIL "${sendmailPath}" - - #undef _PATH_VI - #define _PATH_VI "${vim}/bin/vim" - - #undef _PATH_DEFPATH - #define _PATH_DEFPATH "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin" - __EOT__ - - # Implicit saved uids do not work here due to way NixOS uses setuid wrappers - # (#16518). - echo "#undef HAVE_SAVED_UIDS" >> externs.h + unpackCmd = '' + mkdir cron + pushd cron + sh $curSrc + popd ''; - preInstall = "mkdir -p $out/bin $out/sbin $out/share/man/man1 $out/share/man/man5 $out/share/man/man8"; + # do not set sticky bit in /nix/store + # further, do not strip during install since it breaks on cross-compilation + # and we will do this ourselves as needed + postPatch = '' + substituteInPlace Makefile \ + --replace ' -o root' ' ' \ + --replace 111 755 \ + --replace 4755 0755 \ + --replace ' -s cron' ' cron' + ''; - meta = with lib; { - description = "Daemon for running commands at specific times (Vixie Cron)"; - license = licenses.bsd0; - platforms = with platforms; linux ++ darwin; + preInstall = '' + mkdir -p $out/{{,s}bin,share/man/man{1,5,8}} + ''; + + meta = { + homepage = "https://ftp.isc.org/isc/cron/"; + description = "Daemon for running commands at specific times"; + license = lib.licenses.bsd0; + mainProgram = "cron"; + maintainers = with lib.maintainers; [ AndersonTorres ]; + platforms = lib.platforms.unix; }; -} +})