Commit 763ed867 authored by Anderson Torres's avatar Anderson Torres
Browse files

rc: unstable-2021-08-03 -> unstable-2023-06-14

parent 631b5b9c
Loading
Loading
Loading
Loading
+65 −28
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, autoreconfHook, byacc
, ncurses, readline, pkgsStatic
, historySupport ? false, readlineSupport ? true }:
{ lib
, stdenv
, fetchFromGitHub
, byacc
, ed
, ncurses
, readline
, installShellFiles
, pkgsStatic
, historySupport ? true
, readlineSupport ? true
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "rc";
  version = "unstable-2021-08-03";
  version = "unstable-2023-06-14";

  src = fetchFromGitHub {
    owner = "rakitzis";
    repo = "rc";
    rev = "8ca9ab1305c3e30cd064290081d6e5a1fa841d26";
    sha256 = "0744ars6y9zzsjr9xazms91qy6bi7msg2gg87526waziahfh4s4z";
    rev = "4aaba1a9cb9fdbb8660696a87850836ffdb09599";
    hash = "sha256-Yql3mt7hTO2W7wTfPje+X2zBGTHiNXGGXYORJewJIM8=";
  };

  strictDeps = true;
  nativeBuildInputs = [ autoreconfHook byacc ];
  outputs = [ "out" "man" ];

  # acinclude.m4 wants headers for tgetent().
  buildInputs = [ ncurses ]
    ++ lib.optionals readlineSupport [ readline ];
  # TODO: think on a less ugly fixup
  postPatch = ''
    ed -v -s Makefile << EOS
    # - remove reference to now-inexistent git index file
    /version.h:/ s| .git/index||
    # - manually insert the git revision string
    /v=/ c
    ${"\t"}v=${builtins.substring 0 7 finalAttrs.src.rev}
    .
    /\.git\/index:/ d
    w
    q
    EOS
  '';

  CPPFLAGS = ["-DSIGCLD=SIGCHLD"];
  nativeBuildInputs = [
    byacc
    ed
    installShellFiles
  ];

  configureFlags = [
    "--enable-def-interp=${stdenv.shell}" #183
    ] ++ lib.optionals historySupport [ "--with-history" ]
    ++ lib.optionals readlineSupport [ "--with-edit=readline" ];
  buildInputs = [
    ncurses
  ]
  ++ lib.optionals readlineSupport [
    readline
  ];

  #reproducible-build
  postPatch = ''
    substituteInPlace configure.ac \
      --replace "$(git describe || echo '(git description unavailable)')" "${builtins.substring 0 7 src.rev}"
  strictDeps = true;

  makeFlags  = [
    "CC=${stdenv.cc.targetPrefix}cc"
    "PREFIX=${placeholder "out"}"
    "MANPREFIX=${placeholder "man"}/share/man"
    "CPPFLAGS=\"-DSIGCLD=SIGCHLD\""
  ];

  buildFlags = [
    "all"
  ] ++ lib.optionals historySupport [
    "history"
  ];

  postInstall = lib.optionalString historySupport ''
    installManPage history.1
  '';

  passthru = {
@@ -38,13 +76,12 @@ stdenv.mkDerivation rec {
    tests.static = pkgsStatic.rc;
  };

  meta = with lib; {
  meta = {
    homepage = "https://github.com/rakitzis/rc";
    description = "The Plan 9 shell";
    longDescription = "Byron Rakitzis' UNIX reimplementation of Tom Duff's Plan 9 shell";
    homepage = "https://web.archive.org/web/20180820053030/tobold.org/article/rc";
    license = with licenses; zlib;
    maintainers = with maintainers; [ ramkromberg ];
    license = lib.licenses.zlib;
    maintainers = with lib.maintainers; [ ramkromberg AndersonTorres ];
    platforms = lib.platforms.unix;
    mainProgram = "rc";
    platforms = with platforms; all;
  };
}
})