oils-for-unix-from-source/package.nix

139 lines
3.1 KiB
Nix
Raw Normal View History

{
lib,
stdenv,
fetchFromGitHub,
callPackage,
2026-02-16 12:28:25 -08:00
symlinkJoin,
pkg-config,
ninja,
git,
which,
time,
readline,
2026-02-16 12:28:25 -08:00
ncurses,
zlib,
libffi,
}:
2026-02-16 15:53:59 -08:00
stdenv.mkDerivation (finalAttrs: {
pname = "oils-for-unix";
version = "0.37.0";
src = fetchFromGitHub {
owner = "oils-for-unix";
repo = "oils";
2026-02-16 15:53:59 -08:00
rev = "release/${finalAttrs.version}";
hash = "sha256-d2i2P8ZiGb+FYzZIzs0pY2gIRQGGuenLbxrGhafVxVc=";
};
nativeBuildInputs = [
2026-02-16 12:28:25 -08:00
pkg-config
ninja
git
which
time
];
2026-02-16 12:28:25 -08:00
buildInputs = [
readline
ncurses
zlib
libffi
];
postPatch = ''
patchShebangs .
substituteInPlace build/dynamic-deps.sh \
--replace-quiet '/usr/bin/env' "$(command -v env)"
substituteInPlace pyext/posixmodule.c \
--replace-quiet '_PyVerify_fd(fd)' '1'
substituteInPlace doctools/cmark.py \
--replace-quiet "raise AssertionError('bin/cmark not found')" \
2026-02-16 15:53:59 -08:00
"cmark_path = '${finalAttrs.passthru.wedge.cmark}/bin/cmark'"
'';
2026-02-16 15:53:59 -08:00
configureFlags = [
"--datarootdir=${placeholder "out"}"
"--with-readline"
"--readline=${finalAttrs.passthru.wedge.readline-all}"
];
buildPhase = ''
runHook preBuild
2026-02-16 12:28:25 -08:00
build/py.sh configure-for-dev
build/stamp.sh write-git-commit
build/py.sh py-source
build/py.sh py-extensions
build/doc.sh all-ref
./NINJA-config.sh
ninja _bin/cxx-opt/oils-for-unix
2026-02-16 12:28:25 -08:00
runHook postBuild
'';
installPhase = ''
runHook preInstall
2026-02-16 12:28:25 -08:00
mkdir -p $out/bin
install -m755 _bin/cxx-opt/oils-for-unix $out/bin/oils-for-unix
ln -s oils-for-unix $out/bin/osh
ln -s oils-for-unix $out/bin/ysh
2026-02-16 12:28:25 -08:00
runHook postInstall
'';
2026-02-16 15:53:59 -08:00
env = {
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=incompatible-function-pointer-types";
PYTHONPATH = "${finalAttrs.passthru.wedge.mypy}:${finalAttrs.passthru.wedge.py3-libs}/lib/python3.10/site-packages:.:vendor/";
LD_LIBRARY_PATH = "${finalAttrs.passthru.wedge.python2}/lib:${finalAttrs.passthru.wedge.python3}/lib";
};
preBuild = ''
export PATH="${
lib.makeBinPath [
finalAttrs.passthru.wedge.python2
finalAttrs.passthru.wedge.python3
finalAttrs.passthru.wedge.re2c
finalAttrs.passthru.wedge.cmark
finalAttrs.passthru.wedge.py3-libs
]
}:$PATH"
'';
meta = {
2026-02-16 12:28:25 -08:00
description = "Oils is our upgrade path from bash to a better language and runtime";
homepage = "https://www.oilshell.org/";
license = lib.licenses.asl20;
2026-02-16 12:28:25 -08:00
platforms = lib.platforms.unix;
mainProgram = "osh";
};
2026-02-16 12:28:25 -08:00
passthru = {
2026-02-16 15:53:59 -08:00
wedge = callPackage ./wedge.nix { oilsSrc = finalAttrs.src; };
2026-02-16 12:28:25 -08:00
withSrc = newSrc: finalAttrs.finalPackage.overrideAttrs { src = newSrc; };
}
// (
let
mkShell =
shellName:
symlinkJoin {
2026-02-16 15:53:59 -08:00
name = "oils-for-unix-${shellName}-${finalAttrs.version}";
paths = [ finalAttrs.finalPackage ];
passthru.shellPath = "/bin/${shellName}";
meta = finalAttrs.meta // {
mainProgram = shellName;
};
};
in
{
osh = mkShell "osh";
ysh = mkShell "ysh";
2026-02-16 12:28:25 -08:00
}
);
})