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
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
result
|
||||||
12
README.md
Normal file
12
README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# oils-for-unix from source
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NIXPKGS_ALLOW_INSECURE=1 nix-build .
|
||||||
|
```
|
||||||
|
|
||||||
|
The build uses Python 2 for legacy build scripts. Python 2, marked insecure in nixpkgs, is not present in the final binaries.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
- `oils-for-unix-0.37.0.nix` - from-source Oils
|
||||||
|
- `mypy-0.780.nix` - mypy 0.780 (last version to support --py2) built without mypyc
|
||||||
5
default.nix
Normal file
5
default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
pkgs ? import <nixpkgs> { },
|
||||||
|
}:
|
||||||
|
|
||||||
|
pkgs.callPackage ./oils-for-unix-0.37.0.nix { }
|
||||||
40
mypy-0.780.nix
Normal file
40
mypy-0.780.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
fetchFromGitHub,
|
||||||
|
python3,
|
||||||
|
}:
|
||||||
|
|
||||||
|
python3.pkgs.buildPythonPackage rec {
|
||||||
|
pname = "mypy";
|
||||||
|
# This is the version oils-for-unix uses for mycpp Python-to-C++ translation
|
||||||
|
version = "0.780";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "python";
|
||||||
|
repo = "mypy";
|
||||||
|
rev = "v${version}";
|
||||||
|
# Fetch submodules to include typeshed (required for type stubs)
|
||||||
|
fetchSubmodules = true;
|
||||||
|
hash = "sha256-czwCx6ZjCu3CrVmbI6NbstzWM0GvuPTWJiiUhXSznu4=";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Do not use mypyc to compile.
|
||||||
|
# Rather, build interpreted so mycpp can extend its classes.
|
||||||
|
preBuild = ''
|
||||||
|
export MYPY_USE_MYPYC=0
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Skip tests to speed up build
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
dependencies = with python3.pkgs; [
|
||||||
|
mypy-extensions
|
||||||
|
typing-extensions
|
||||||
|
typed-ast
|
||||||
|
];
|
||||||
|
|
||||||
|
# Ensure we're not pulling in a compiled version
|
||||||
|
pythonImportsCheck = [ "mypy" ];
|
||||||
|
|
||||||
|
meta.license = lib.licenses.mit;
|
||||||
|
}
|
||||||
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