snix/users/sterni/acme/plan9port/default.nix
sterni 623ebc615f feat(sterni/acme/plan9port): make my plumbing rules the default
To avoid the need for two different versions of plan9port in the CI
pipeline, just move the plumbing sanity check into installCheckPhase.
For local iteration you'd have a plumber running anyways, so the short
build time of the plumb derivation isn't really a necessity.

Change-Id: Ib0ba5fa2d8107530fb7d1144cf7395f4f5a3cd12
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13035
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
2025-01-21 20:19:56 +00:00

49 lines
1.3 KiB
Nix

{ pkgs, lib, ... }:
let
patchesFromDir = dir:
lib.filter
(lib.hasSuffix ".patch")
(lib.mapAttrsToList
(name: _: dir + "/${name}")
(builtins.readDir dir));
mkbqnkeyboard' = pkgs.writeShellScript "mkbqnkeyboard'" ''
exec ${pkgs.cbqn}/bin/BQN ${../mkbqnkeyboard.bqn} -s -i \
"${pkgs.srcOnly pkgs.mbqn}/editors/inputrc" "$1"
'';
in
pkgs.plan9port.overrideAttrs (old: {
patches = old.patches or [ ] ++ patchesFromDir ./.;
postPatch = old.postPatch or "" + ''
${mkbqnkeyboard'} lib/keyboard
cp --reflink=auto ${./../plumb}/* plumb/
mv plumb/sterni.plumbing plumb/initial.plumbing
'';
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
pkgs.buildPackages.makeWrapper
];
# Make some tools (that don't clash) available in PATH directly
postInstall = old.postInstall or "" + ''
for cmd in 9p 9pfuse; do
makeWrapper "$out/plan9/bin/$cmd" "$out/bin/$cmd" \
--set PLAN9 "$out/plan9"
done
'';
doInstallCheck = true;
installCheckPhase = old.installCheckPhase or "" + ''
export NAMESPACE="$(mktemp -d)"
"$out/bin/9" plumber -f &
pid="$!"
until [[ -e "$NAMESPACE/plumb" ]]; do
sleep 0.1
done
"$out/bin/9" 9p write plumb/rules < ${./../plumb}/sterni.plumbing
kill "$pid"
'';
})