Files
nixpkgs/pkgs/by-name/rc/rc-9front/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

83 lines
2.3 KiB
Nix

{
lib,
stdenv,
fetchFrom9Front,
unstableGitUpdater,
byacc,
installShellFiles,
coreutils,
# for tests only
rc-9front,
runCommand,
nawk,
}:
stdenv.mkDerivation {
pname = "rc-9front";
version = "0-unstable-2025-06-14";
src = fetchFrom9Front {
domain = "shithub.us";
owner = "cinap_lenrek";
repo = "rc";
rev = "3e907e648d7263c159c604dc51aa8ca5d5fcd7f8";
hash = "sha256-XucMQXlGdMcs3piMKRgmQNhuirSQP9mKmXbfTWbuePg=";
};
strictDeps = true;
nativeBuildInputs = [
byacc
installShellFiles
];
enableParallelBuilding = true;
# Rc bootstraps the new $path by hardcoding a common list
# of binary locations common to most POSIX-y systems.
# On NixOS the average $PATH is a lot more involved and
# as such the resulting environment that rcmain.unix dumps you
# into is not particularly useful. This patch instead makes
# rc bootstrap the new $path using the existing $PATH.
postPatch = ''
substituteInPlace ./rcmain.unix --replace-fail 'path=(. /bin /usr/bin /usr/local/bin)' 'path=`:{${coreutils}/bin/env echo -n $PATH}'
'';
makeFlags = [ "PREFIX=$(out)" ];
installPhase = ''
runHook preInstall
install -Dm755 -t $out/bin/ rc
installManPage rc.1
mkdir -p $out/lib
install -m644 rcmain.unix $out/lib/rcmain
runHook postInstall
'';
passthru = {
shellPath = "/bin/rc";
updateScript = unstableGitUpdater { shallowClone = false; };
tests = {
simple = runCommand "rc-test" { } ''
${lib.getExe rc-9front} -c 'nl=`{echo} && \
res=`$nl{for(i in `{seq 1 10}) echo $i} && \
echo -n $res' >$out
[ "$(wc -l $out | ${lib.getExe nawk} '{ print $1 }' )" = 10 ]
[ "$(${lib.getExe nawk} '{ a=a+$1 } END{ print a }' < $out)" = "$((10+9+8+7+6+5+4+3+2+1))" ]
'';
path = runCommand "rc-path" { } ''
PATH='${coreutils}/bin:/a:/b:/c' ${lib.getExe rc-9front} -c 'echo $path(2-)' >$out
[ '/a /b /c' = "$(cat $out)" ]
'';
};
};
meta = {
description = "9front shell";
longDescription = "unix port of 9front rc";
homepage = "http://shithub.us/cinap_lenrek/rc/HEAD/info.html";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ moody ];
mainProgram = "rc";
platforms = lib.platforms.all;
};
}