Unverified Commit 48614c89 authored by Thiago Kenji Okada's avatar Thiago Kenji Okada Committed by GitHub
Browse files

Merge pull request #336670 from museoa/cronie

Cronie: a new cron
parents 0d10c042 e0064776
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
{
  lib,
  autoreconfHook,
  fetchFromGitHub,
  stdenv,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "cronie";
  version = "1.7.2";

  src = fetchFromGitHub {
    owner = "cronie-crond";
    repo = "cronie";
    rev = "cronie-${finalAttrs.version}";
    hash = "sha256-WrzdpE9t7vWpc8QFoFs+S/HgHwsidRNmfcHp7ltSWQw=";
  };

  nativeBuildInputs = [ autoreconfHook ];

  outputs = [
    "out"
    "man"
  ];

  strictDeps = true;

  meta = {
    homepage = "https://github.com/cronie-crond/cronie";
    description = "Cron replacement, based on vixie-cron";
    changelog = "https://github.com/cronie-crond/cronie/blob/master/ChangeLog";
    license = with lib.licenses; [
      gpl2Plus
      isc
      lgpl21Plus
    ];
    mainProgram = "crond";
    maintainers = with lib.maintainers; [ AndersonTorres ];
    platforms = lib.platforms.all;
  };
})
+45 −0
Original line number Diff line number Diff line
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_ */
+71 −0
Original line number Diff line number Diff line
{
  lib,
  fetchurl,
  stdenv,
  substituteAll,
  vim,
  sendmailPath ? "/usr/sbin/sendmail",
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "cron";
  version = "4.1";

  src = fetchurl {
    url = "ftp://ftp.isc.org/isc/cron/cron_${finalAttrs.version}.shar";
    hash = "sha256-xEWDd1b7mI8slduNxV15N9FLygzfopLegTIsolVuw5o=";
  };

  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" ];

  unpackCmd = ''
    mkdir cron
    pushd cron
    sh $curSrc
    popd
  '';

  # 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'
  '';

  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;
  };
})
+0 −49
Original line number Diff line number Diff line
{lib, stdenv, fetchurl, vim, sendmailPath ? "/usr/sbin/sendmail"}:

stdenv.mkDerivation rec {
  pname = "cron";
  version = "4.1";

  src = fetchurl {
    url = "ftp://ftp.isc.org/isc/cron/cron_${version}.shar";
    sha256 = "16n3dras4b1jh7g958nz1k54pl9pg5fwb3fvjln8z67varvq6if4";
  };

  unpackCmd = "(mkdir cron && cd cron && sh $curSrc)";

  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
  '';

  preInstall = "mkdir -p $out/bin $out/sbin $out/share/man/man1 $out/share/man/man5 $out/share/man/man8";

  meta = with lib; {
    description = "Daemon for running commands at specific times (Vixie Cron)";
    license = licenses.bsd0;
    platforms = with platforms; linux ++ darwin;
  };
}
+1 −1
Original line number Diff line number Diff line
@@ -6897,7 +6897,7 @@ with pkgs;
  cromfs = callPackage ../tools/archivers/cromfs { };
  cron = callPackage ../tools/system/cron { };
  cron = isc-cron;
  ctlptl = callPackage ../development/tools/ctlptl { };