Create a from-source Nix package for oils-for-nix
This commit is contained in:
commit
5f14fab320
5 changed files with 194 additions and 0 deletions
136
oils-for-unix-0.37.0.nix
Normal file
136
oils-for-unix-0.37.0.nix
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
symlinkJoin,
|
||||
callPackage,
|
||||
# Build tools
|
||||
python2, # Legacy build scripts. Marked insecure but not in final binary
|
||||
python310, # Newest version that supports mypy 0.780's typeshed
|
||||
re2c,
|
||||
ninja,
|
||||
git,
|
||||
cmark,
|
||||
which,
|
||||
time,
|
||||
readline,
|
||||
}:
|
||||
|
||||
let
|
||||
# mypy 0.780 is the last version with --py2 support
|
||||
# built without mypyc so mycpp can extend its classes
|
||||
mypy-for-mycpp = callPackage ./mypy-0.780.nix { python3 = python310; };
|
||||
|
||||
python = python310.withPackages (ps: [
|
||||
mypy-for-mycpp
|
||||
ps.typing-extensions
|
||||
]);
|
||||
|
||||
# Configure script expects readline lib and headers at the same prefix
|
||||
readline-all = symlinkJoin {
|
||||
name = "readline-all";
|
||||
paths = [
|
||||
readline
|
||||
readline.dev
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "oils-for-unix";
|
||||
version = "0.37.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "oils-for-unix";
|
||||
repo = "oils";
|
||||
# Reference by release branch
|
||||
rev = "release/${finalAttrs.version}";
|
||||
hash = "sha256-d2i2P8ZiGb+FYzZIzs0pY2gIRQGGuenLbxrGhafVxVc=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
python2
|
||||
python
|
||||
re2c
|
||||
ninja
|
||||
git
|
||||
cmark
|
||||
which
|
||||
time
|
||||
];
|
||||
|
||||
buildInputs = [ readline ];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs .
|
||||
|
||||
substituteInPlace build/dynamic-deps.sh \
|
||||
--replace-quiet '/usr/bin/env' "$(command -v env)"
|
||||
|
||||
# _PyVerify_fd is Windows-only
|
||||
substituteInPlace pyext/posixmodule.c \
|
||||
--replace-quiet '_PyVerify_fd(fd)' '1'
|
||||
|
||||
substituteInPlace doctools/cmark.py \
|
||||
--replace-quiet "raise AssertionError('bin/cmark not found')" \
|
||||
"cmark_path = '${cmark}/bin/cmark'"
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
./configure \
|
||||
--datarootdir=$out \
|
||||
--with-readline \
|
||||
--readline=${readline-all}
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
. build/dev-shell.sh
|
||||
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
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
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
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# Suppress warnings from older C code in vendor dependencies
|
||||
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=incompatible-function-pointer-types";
|
||||
|
||||
meta = {
|
||||
license = lib.licenses.asl20;
|
||||
platforms = lib.platforms.all;
|
||||
mainProgram = "osh";
|
||||
};
|
||||
|
||||
passthru =
|
||||
let
|
||||
mkShell =
|
||||
shellName:
|
||||
symlinkJoin {
|
||||
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";
|
||||
};
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue