Migrate to wedges
This commit is contained in:
parent
cf19b5725f
commit
cda034b29e
8 changed files with 242 additions and 151 deletions
174
wedges.nix
Normal file
174
wedges.nix
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
# Wedge derivations for oils-for-unix
|
||||
#
|
||||
# These mirror oils' upstream wedge system (build/deps.sh):
|
||||
# - Python 2.7 and 3.10 built from official tarballs
|
||||
# - mypy and dependencies downloaded via pip (FOD)
|
||||
# - mypy installed in a venv from cached packages
|
||||
|
||||
{
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchurl,
|
||||
symlinkJoin,
|
||||
pkg-config,
|
||||
cacert,
|
||||
openssl,
|
||||
zlib,
|
||||
libffi,
|
||||
readline,
|
||||
ncurses,
|
||||
bzip2,
|
||||
xz,
|
||||
gdbm,
|
||||
sqlite,
|
||||
}:
|
||||
|
||||
let
|
||||
mkPythonWedge =
|
||||
{
|
||||
version,
|
||||
hash,
|
||||
extraConfigureFlags ? [ ],
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "oils-python-wedge";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://www.python.org/ftp/python/${finalAttrs.version}/Python-${finalAttrs.version}.tar.xz";
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [
|
||||
readline
|
||||
ncurses
|
||||
zlib
|
||||
bzip2
|
||||
openssl
|
||||
libffi
|
||||
xz
|
||||
gdbm
|
||||
sqlite
|
||||
];
|
||||
|
||||
env = {
|
||||
CPPFLAGS = "-I${zlib.dev}/include -I${libffi.dev}/include";
|
||||
LDFLAGS = "-L${zlib}/lib -L${libffi}/lib -Wl,-rpath,${placeholder "out"}/lib";
|
||||
PKG_CONFIG_PATH = "${libffi.dev}/lib/pkgconfig:${zlib.dev}/lib/pkgconfig:${openssl.dev}/lib/pkgconfig";
|
||||
LIBFFI_INCLUDEDIR = "${libffi.dev}/include";
|
||||
LIBFFI_LIBDIR = "${libffi}/lib";
|
||||
};
|
||||
|
||||
configureFlags = [
|
||||
"--enable-shared"
|
||||
"--with-system-ffi"
|
||||
] ++ extraConfigureFlags;
|
||||
|
||||
doCheck = false;
|
||||
enableParallelBuilding = true;
|
||||
});
|
||||
|
||||
python2Wedge = mkPythonWedge {
|
||||
version = "2.7.18";
|
||||
hash = "sha256-tiwOeTdVHQzAK4/Vyw9UT5QFuvyaVNOAjtRZSBLt70M=";
|
||||
extraConfigureFlags = [
|
||||
"--enable-unicode=ucs4"
|
||||
"--with-ensurepip=no"
|
||||
];
|
||||
};
|
||||
|
||||
python3Wedge = mkPythonWedge {
|
||||
version = "3.10.4";
|
||||
hash = "sha256-gL+SX1cdpDazUhCIbPefbrX6XWxXExa3NWg0NFH3ehk=";
|
||||
extraConfigureFlags = [
|
||||
"--with-ensurepip=install"
|
||||
];
|
||||
};
|
||||
|
||||
py3LibsCache = stdenv.mkDerivation {
|
||||
name = "oils-py3-libs-cache";
|
||||
|
||||
nativeBuildInputs = [
|
||||
python3Wedge
|
||||
cacert
|
||||
];
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
buildPhase = ''
|
||||
export HOME=$TMPDIR
|
||||
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
|
||||
mkdir -p $out
|
||||
|
||||
${python3Wedge}/bin/pip3 install --upgrade pip setuptools wheel
|
||||
|
||||
# Download exact versions (see requirements.txt)
|
||||
${python3Wedge}/bin/pip3 download -d $out --only-binary=:all: --no-deps \
|
||||
-r ${./requirements.txt}
|
||||
'';
|
||||
|
||||
dontInstall = true;
|
||||
|
||||
outputHashMode = "recursive";
|
||||
outputHash = "sha256-dTO5D4vr42A7Pui0i8ggt8rD6xQplG17rGB76M4ntRY=";
|
||||
};
|
||||
|
||||
mypyWedge = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "oils-mypy-wedge";
|
||||
version = "0.780";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "python";
|
||||
repo = "mypy";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-czwCx6ZjCu3CrVmbI6NbstzWM0GvuPTWJiiUhXSznu4=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ python3Wedge ];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export HOME=$TMPDIR
|
||||
|
||||
${python3Wedge}/bin/python3 -m venv $out
|
||||
|
||||
# Install all packages from cached wheels (--no-deps to bypass version conflicts)
|
||||
$out/bin/pip install \
|
||||
--no-index \
|
||||
--find-links=${py3LibsCache} \
|
||||
--no-deps \
|
||||
setuptools wheel packaging \
|
||||
typing_extensions mypy_extensions typed_ast \
|
||||
mypy
|
||||
|
||||
# Copy mypy source (mycpp extends mypy classes)
|
||||
cp -r . $out/mypy-src
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
dontInstall = true;
|
||||
dontFixup = true;
|
||||
});
|
||||
|
||||
readline-all = symlinkJoin {
|
||||
name = "readline-all";
|
||||
paths = [
|
||||
readline
|
||||
readline.dev
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
inherit
|
||||
python2Wedge
|
||||
python3Wedge
|
||||
mypyWedge
|
||||
readline-all
|
||||
;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue