about summary refs log tree commit diff
path: root/pkgs/by-name/rc
diff options
context:
space:
mode:
authorAnderson Torres <torres.anderson.85@protonmail.com>2023-09-09 18:05:59 -0300
committerAnderson Torres <torres.anderson.85@protonmail.com>2023-09-19 00:02:22 -0300
commit88a627e01273c4301e3ab533a5e85fea51d5ecd9 (patch)
tree2412b9fdadace98f33c87ab7f4b238403e8de491 /pkgs/by-name/rc
parentfd09de7be5279da58b5f6b417cc9f40def8d4b7d (diff)
rc: migrate to by-name
Diffstat (limited to 'pkgs/by-name/rc')
-rw-r--r--pkgs/by-name/rc/rc/package.nix95
1 files changed, 95 insertions, 0 deletions
diff --git a/pkgs/by-name/rc/rc/package.nix b/pkgs/by-name/rc/rc/package.nix
new file mode 100644
index 0000000000000..1e1e968e73330
--- /dev/null
+++ b/pkgs/by-name/rc/rc/package.nix
@@ -0,0 +1,95 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, pkgsStatic
+, byacc
+, ed
+, ncurses
+, readline
+, installShellFiles
+, historySupport ? true
+, readlineSupport ? true
+, lineEditingLibrary ? if (stdenv.hostPlatform.isDarwin
+                           || stdenv.hostPlatform.isStatic)
+                       then "null"
+                       else "readline"
+}:
+
+assert lib.elem lineEditingLibrary [ "null" "edit" "editline" "readline" "vrl" ];
+assert !(lib.elem lineEditingLibrary [ "edit" "editline" "vrl" ]); # broken
+assert (lineEditingLibrary == "readline") -> readlineSupport;
+stdenv.mkDerivation (finalAttrs: {
+  pname = "rc";
+  version = "unstable-2023-06-14";
+
+  src = fetchFromGitHub {
+    owner = "rakitzis";
+    repo = "rc";
+    rev = "4aaba1a9cb9fdbb8660696a87850836ffdb09599";
+    hash = "sha256-Yql3mt7hTO2W7wTfPje+X2zBGTHiNXGGXYORJewJIM8=";
+  };
+
+  outputs = [ "out" "man" ];
+
+  # 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
+  '';
+
+  nativeBuildInputs = [
+    byacc
+    ed
+    installShellFiles
+  ];
+
+  buildInputs = [
+    ncurses
+  ]
+  ++ lib.optionals readlineSupport [
+    readline
+  ];
+
+  strictDeps = true;
+
+  makeFlags  = [
+    "CC=${stdenv.cc.targetPrefix}cc"
+    "PREFIX=${placeholder "out"}"
+    "MANPREFIX=${placeholder "man"}/share/man"
+    "CPPFLAGS=\"-DSIGCLD=SIGCHLD\""
+    "EDIT=${lineEditingLibrary}"
+  ];
+
+  buildFlags = [
+    "all"
+  ] ++ lib.optionals historySupport [
+    "history"
+  ];
+
+  postInstall = lib.optionalString historySupport ''
+    installManPage history.1
+  '';
+
+  passthru = {
+    shellPath = "/bin/rc";
+    tests.static = pkgsStatic.rc;
+  };
+
+  meta = {
+    homepage = "https://github.com/rakitzis/rc";
+    description = "The Plan 9 shell";
+    license = [ lib.licenses.zlib ];
+    mainProgram = "rc";
+    maintainers = with lib.maintainers; [ ramkromberg AndersonTorres ];
+    platforms = lib.platforms.unix;
+  };
+})