uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
93
pkgs/development/tools/ocaml/opam/1.2.2.nix
Normal file
93
pkgs/development/tools/ocaml/opam/1.2.2.nix
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
{ stdenv, lib, fetchurl, makeWrapper,
|
||||
ocaml, unzip, ncurses, curl, aspcud
|
||||
}:
|
||||
|
||||
assert lib.versionAtLeast ocaml.version "3.12.1";
|
||||
|
||||
let
|
||||
srcs = {
|
||||
cudf = fetchurl {
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/33593/cudf-0.7.tar.gz";
|
||||
sha256 = "92c8a9ed730bbac73f3513abab41127d966c9b9202ab2aaffcd02358c030a701";
|
||||
};
|
||||
extlib = fetchurl {
|
||||
url = "http://ocaml-extlib.googlecode.com/files/extlib-1.5.3.tar.gz";
|
||||
sha256 = "c095eef4202a8614ff1474d4c08c50c32d6ca82d1015387785cf03d5913ec021";
|
||||
};
|
||||
ocaml_re = fetchurl {
|
||||
url = "https://github.com/ocaml/ocaml-re/archive/ocaml-re-1.2.0.tar.gz";
|
||||
sha256 = "a34dd9d6136731436a963bbab5c4bbb16e5d4e21b3b851d34887a3dec451999f";
|
||||
};
|
||||
ocamlgraph = fetchurl {
|
||||
url = "http://ocamlgraph.lri.fr/download/ocamlgraph-1.8.5.tar.gz";
|
||||
sha256 = "d167466435a155c779d5ec25b2db83ad851feb42ebc37dca8ffa345ddaefb82f";
|
||||
};
|
||||
dose3 = fetchurl {
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/34277/dose3-3.3.tar.gz";
|
||||
sha256 = "8dc4dae9b1a81bb3a42abb283df785ba3eb00ade29b13875821c69f03e00680e";
|
||||
};
|
||||
cmdliner = fetchurl {
|
||||
url = "https://erratique.ch/software/cmdliner/releases/cmdliner-0.9.7.tbz";
|
||||
sha256 = "9c19893cffb5d3c3469ee0cce85e3eeeba17d309b33b9ace31aba06f68f0bf7a";
|
||||
};
|
||||
uutf = fetchurl {
|
||||
url = "https://erratique.ch/software/uutf/releases/uutf-0.9.3.tbz";
|
||||
sha256 = "1f364f89b1179e5182a4d3ad8975f57389d45548735d19054845e06a27107877";
|
||||
};
|
||||
jsonm = fetchurl {
|
||||
url = "https://erratique.ch/software/jsonm/releases/jsonm-0.9.1.tbz";
|
||||
sha256 = "3fd4dca045d82332da847e65e981d8b504883571d299a3f7e71447d46bc65f73";
|
||||
};
|
||||
opam = fetchurl {
|
||||
url = "https://github.com/ocaml/opam/archive/1.2.2.zip";
|
||||
sha256 = "c590ce55ae69ec74f46215cf16a156a02b23c5f3ecb22f23a3ad9ba3d91ddb6e";
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation {
|
||||
pname = "opam";
|
||||
version = "1.2.2";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
buildInputs = [ curl ncurses ocaml ];
|
||||
|
||||
src = srcs.opam;
|
||||
|
||||
postUnpack = ''
|
||||
ln -sv ${srcs.cudf} $sourceRoot/src_ext/${srcs.cudf.name}
|
||||
ln -sv ${srcs.extlib} $sourceRoot/src_ext/${srcs.extlib.name}
|
||||
ln -sv ${srcs.ocaml_re} $sourceRoot/src_ext/${srcs.ocaml_re.name}
|
||||
ln -sv ${srcs.ocamlgraph} $sourceRoot/src_ext/${srcs.ocamlgraph.name}
|
||||
ln -sv ${srcs.dose3} $sourceRoot/src_ext/${srcs.dose3.name}
|
||||
ln -sv ${srcs.cmdliner} $sourceRoot/src_ext/${srcs.cmdliner.name}
|
||||
ln -sv ${srcs.uutf} $sourceRoot/src_ext/${srcs.uutf.name}
|
||||
ln -sv ${srcs.jsonm} $sourceRoot/src_ext/${srcs.jsonm.name}
|
||||
'';
|
||||
|
||||
preConfigure = ''
|
||||
substituteInPlace ./src_ext/Makefile --replace "%.stamp: %.download" "%.stamp:"
|
||||
'';
|
||||
|
||||
postConfigure = "make lib-ext";
|
||||
|
||||
# Dirty, but apparently ocp-build requires a TERM
|
||||
makeFlags = ["TERM=screen"];
|
||||
|
||||
# change argv0 to "opam" as a workaround for
|
||||
# https://github.com/ocaml/opam/issues/2142
|
||||
postInstall = ''
|
||||
mv $out/bin/opam $out/bin/.opam-wrapped
|
||||
makeWrapper $out/bin/.opam-wrapped $out/bin/opam \
|
||||
--argv0 "opam" \
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A package manager for OCaml";
|
||||
homepage = "http://opam.ocamlpro.com/";
|
||||
maintainers = [ maintainers.henrytill ];
|
||||
platforms = platforms.all;
|
||||
license = licenses.lgpl21Plus;
|
||||
};
|
||||
}
|
||||
136
pkgs/development/tools/ocaml/opam/default.nix
Normal file
136
pkgs/development/tools/ocaml/opam/default.nix
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
{ stdenv, lib, fetchurl, makeWrapper, getconf,
|
||||
ocaml, unzip, ncurses, curl, aspcud, bubblewrap
|
||||
}:
|
||||
|
||||
assert lib.versionAtLeast ocaml.version "4.02.3";
|
||||
|
||||
let
|
||||
srcs = {
|
||||
"0install-solver" = fetchurl {
|
||||
url = "https://github.com/0install/0install/releases/download/v2.17/0install-v2.17.tbz";
|
||||
sha256 = "08q95mzmf9pyyqs68ff52422f834hi313cxmypwrxmxsabcfa10p";
|
||||
};
|
||||
"cmdliner" = fetchurl {
|
||||
url = "http://erratique.ch/software/cmdliner/releases/cmdliner-1.0.4.tbz";
|
||||
sha256 = "1h04q0zkasd0mw64ggh4y58lgzkhg6yhzy60lab8k8zq9ba96ajw";
|
||||
};
|
||||
"cppo" = fetchurl {
|
||||
url = "https://github.com/ocaml-community/cppo/releases/download/v1.6.7/cppo-v1.6.7.tbz";
|
||||
sha256 = "17ajdzrnmnyfig3s6hinb56mcmhywbssxhsq32dz0v90dhz3wmfv";
|
||||
};
|
||||
"cudf" = fetchurl {
|
||||
url = "https://github.com/ocaml/opam-source-archives/raw/main/cudf-0.9.tar.gz";
|
||||
sha256 = "0771lwljqwwn3cryl0plny5a5dyyrj4z6bw66ha5n8yfbpcy8clr";
|
||||
};
|
||||
"dose3" = fetchurl {
|
||||
url = "https://gitlab.com/irill/dose3/-/archive/5.0.1/dose3-5.0.1.tar.gz";
|
||||
sha256 = "1mh6fv8qbf8xx4h2dc0dpv2lzygvikzjhw1idrknibbwsjw3jg9c";
|
||||
};
|
||||
"dune-local" = fetchurl {
|
||||
url = "https://github.com/ocaml/dune/releases/download/2.9.0/dune-2.9.0.tbz";
|
||||
sha256 = "07m476kgagpd6kzm3jq30yfxqspr2hychah0xfqs14z82zxpq8dv";
|
||||
};
|
||||
"extlib" = fetchurl {
|
||||
url = "https://ygrek.org/p/release/ocaml-extlib/extlib-1.7.7.tar.gz";
|
||||
sha256 = "1sxmzc1mx3kg62j8kbk0dxkx8mkf1rn70h542cjzrziflznap0s1";
|
||||
};
|
||||
"mccs" = fetchurl {
|
||||
url = "https://github.com/AltGr/ocaml-mccs/archive/1.1+13.tar.gz";
|
||||
sha256 = "05nnji9h8mss3hzjr5faid2v3xfr7rcv2ywmpcxxp28y6h2kv9gv";
|
||||
};
|
||||
"ocamlgraph" = fetchurl {
|
||||
url = "https://github.com/backtracking/ocamlgraph/releases/download/2.0.0/ocamlgraph-2.0.0.tbz";
|
||||
sha256 = "029692bvdz3hxpva9a2jg5w5381fkcw55ysdi8424lyyjxvjdzi0";
|
||||
};
|
||||
"opam-0install-cudf" = fetchurl {
|
||||
url = "https://github.com/ocaml-opam/opam-0install-solver/releases/download/v0.4.2/opam-0install-cudf-v0.4.2.tbz";
|
||||
sha256 = "10wma4hh9l8hk49rl8nql6ixsvlz3163gcxspay5fwrpbg51fmxr";
|
||||
};
|
||||
"opam-file-format" = fetchurl {
|
||||
url = "https://github.com/ocaml/opam-file-format/archive/2.1.3.tar.gz";
|
||||
sha256 = "1bqyrlsvmjf4gqzmzbiyja9m1ph30ic9i18x23p5ziymyylw2sfg";
|
||||
};
|
||||
"re" = fetchurl {
|
||||
url = "https://github.com/ocaml/ocaml-re/releases/download/1.9.0/re-1.9.0.tbz";
|
||||
sha256 = "1gas4ky49zgxph3870nffzkr6y41kkpqp4nj38pz1gh49zcf12aj";
|
||||
};
|
||||
"result" = fetchurl {
|
||||
url = "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz";
|
||||
sha256 = "0cpfp35fdwnv3p30a06wd0py3805qxmq3jmcynjc3x2qhlimwfkw";
|
||||
};
|
||||
"seq" = fetchurl {
|
||||
url = "https://github.com/c-cube/seq/archive/0.2.2.tar.gz";
|
||||
sha256 = "1ck15v3pg8bacdg6d6iyp2jc3kgrzxk5jsgzx3287x2ycb897j53";
|
||||
};
|
||||
"stdlib-shims" = fetchurl {
|
||||
url = "https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz";
|
||||
sha256 = "0jnqsv6pqp5b5g7lcjwgd75zqqvcwcl5a32zi03zg1kvj79p5gxs";
|
||||
};
|
||||
opam = fetchurl {
|
||||
url = "https://github.com/ocaml/opam/archive/2.1.2.zip";
|
||||
sha256 = "0yq3dgx869016xrf65xv0glmqill1nk2ad12x3l36l70pn90rmyd";
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation {
|
||||
pname = "opam";
|
||||
version = "2.1.2";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
buildInputs = [ curl ncurses ocaml getconf ] ++ lib.optional stdenv.isLinux bubblewrap;
|
||||
|
||||
src = srcs.opam;
|
||||
|
||||
postUnpack = ''
|
||||
ln -sv ${srcs."0install-solver"} $sourceRoot/src_ext/0install-solver.tbz
|
||||
ln -sv ${srcs."cmdliner"} $sourceRoot/src_ext/cmdliner.tbz
|
||||
ln -sv ${srcs."cppo"} $sourceRoot/src_ext/cppo.tbz
|
||||
ln -sv ${srcs."cudf"} $sourceRoot/src_ext/cudf.tar.gz
|
||||
ln -sv ${srcs."dose3"} $sourceRoot/src_ext/dose3.tar.gz
|
||||
ln -sv ${srcs."dune-local"} $sourceRoot/src_ext/dune-local.tbz
|
||||
ln -sv ${srcs."extlib"} $sourceRoot/src_ext/extlib.tar.gz
|
||||
ln -sv ${srcs."mccs"} $sourceRoot/src_ext/mccs.tar.gz
|
||||
ln -sv ${srcs."ocamlgraph"} $sourceRoot/src_ext/ocamlgraph.tbz
|
||||
ln -sv ${srcs."opam-0install-cudf"} $sourceRoot/src_ext/opam-0install-cudf.tbz
|
||||
ln -sv ${srcs."opam-file-format"} $sourceRoot/src_ext/opam-file-format.tar.gz
|
||||
ln -sv ${srcs."re"} $sourceRoot/src_ext/re.tbz
|
||||
ln -sv ${srcs."result"} $sourceRoot/src_ext/result.tbz
|
||||
ln -sv ${srcs."seq"} $sourceRoot/src_ext/seq.tar.gz
|
||||
ln -sv ${srcs."stdlib-shims"} $sourceRoot/src_ext/stdlib-shims.tbz
|
||||
'';
|
||||
|
||||
patches = [ ./opam-shebangs.patch ];
|
||||
|
||||
preConfigure = ''
|
||||
substituteInPlace ./src_ext/Makefile --replace "%.stamp: %.download" "%.stamp:"
|
||||
patchShebangs src/state/shellscripts
|
||||
'';
|
||||
|
||||
postConfigure = "make lib-ext";
|
||||
|
||||
# Dirty, but apparently ocp-build requires a TERM
|
||||
makeFlags = ["TERM=screen"];
|
||||
|
||||
outputs = [ "out" "installer" ];
|
||||
setOutputFlags = false;
|
||||
|
||||
# change argv0 to "opam" as a workaround for
|
||||
# https://github.com/ocaml/opam/issues/2142
|
||||
postInstall = ''
|
||||
mv $out/bin/opam $out/bin/.opam-wrapped
|
||||
makeWrapper $out/bin/.opam-wrapped $out/bin/opam \
|
||||
--argv0 "opam" \
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin:${lib.optionalString stdenv.isLinux "${bubblewrap}/bin:"}${getconf}/bin \
|
||||
--set OPAM_USER_PATH_RO /run/current-system/sw/bin:/nix/
|
||||
$out/bin/opam-installer --prefix=$installer opam-installer.install
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A package manager for OCaml";
|
||||
homepage = "https://opam.ocaml.org/";
|
||||
maintainers = [ maintainers.henrytill maintainers.marsam ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
# Generated by: ./opam.nix.pl -v 2.1.2 -p opam-shebangs.patch
|
||||
17
pkgs/development/tools/ocaml/opam/installer.nix
Normal file
17
pkgs/development/tools/ocaml/opam/installer.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ lib, unzip, opam, ocamlPackages }:
|
||||
|
||||
ocamlPackages.buildDunePackage {
|
||||
pname = "opam-installer";
|
||||
|
||||
useDune2 = true;
|
||||
|
||||
inherit (opam) version src;
|
||||
nativeBuildInputs = [ unzip ];
|
||||
|
||||
configureFlags = [ "--disable-checks" "--prefix=$out" ];
|
||||
buildInputs = with ocamlPackages; [ opam-format cmdliner ];
|
||||
|
||||
meta = opam.meta // {
|
||||
description = "Handle (un)installation from opam install files";
|
||||
};
|
||||
}
|
||||
131
pkgs/development/tools/ocaml/opam/opam-shebangs.patch
Normal file
131
pkgs/development/tools/ocaml/opam/opam-shebangs.patch
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
diff --git a/src/client/opamInitDefaults.ml b/src/client/opamInitDefaults.ml
|
||||
index eca13a7c..1fd66f43 100644
|
||||
--- a/src/client/opamInitDefaults.ml
|
||||
+++ b/src/client/opamInitDefaults.ml
|
||||
@@ -35,14 +35,18 @@ let eval_variables = [
|
||||
let os_filter os =
|
||||
FOp (FIdent ([], OpamVariable.of_string "os", None), `Eq, FString os)
|
||||
|
||||
+let os_distribution_filter distro =
|
||||
+ FOp (FIdent ([], OpamVariable.of_string "os-distribution", None), `Eq, FString distro)
|
||||
+
|
||||
let linux_filter = os_filter "linux"
|
||||
let macos_filter = os_filter "macos"
|
||||
let openbsd_filter = os_filter "openbsd"
|
||||
let freebsd_filter = os_filter "freebsd"
|
||||
let not_open_free_bsd_filter =
|
||||
FNot (FOr (openbsd_filter, freebsd_filter))
|
||||
let win32_filter = os_filter "win32"
|
||||
let sandbox_filter = FOr (linux_filter, macos_filter)
|
||||
+let nixos_filter = os_distribution_filter "nixos"
|
||||
|
||||
let gpatch_filter = FOr (openbsd_filter, freebsd_filter)
|
||||
let patch_filter = FNot gpatch_filter
|
||||
@@ -50,6 +54,11 @@ let wrappers ~sandboxing () =
|
||||
CString t, None;
|
||||
] in
|
||||
let w = OpamFile.Wrappers.empty in
|
||||
+ let w = { w with
|
||||
+ OpamFile.Wrappers.
|
||||
+ pre_build = [[CString "%{hooks}%/shebangs.sh", None], Some nixos_filter];
|
||||
+ }
|
||||
+ in
|
||||
if sandboxing then
|
||||
{ w with
|
||||
OpamFile.Wrappers.
|
||||
@@ -113,6 +122,7 @@ let required_tools ~sandboxing () =
|
||||
let init_scripts () = [
|
||||
("sandbox.sh", OpamScript.bwrap), Some bwrap_filter;
|
||||
("sandbox.sh", OpamScript.sandbox_exec), Some macos_filter;
|
||||
+ ("shebangs.sh", OpamScript.patch_shebangs), Some nixos_filter;
|
||||
]
|
||||
|
||||
module I = OpamFile.InitConfig
|
||||
diff --git a/src/state/opamScript.mli b/src/state/opamScript.mli
|
||||
index 03449970..83de0b53 100644
|
||||
--- a/src/state/opamScript.mli
|
||||
+++ b/src/state/opamScript.mli
|
||||
@@ -20,3 +20,4 @@ val env_hook : string
|
||||
val env_hook_zsh : string
|
||||
val env_hook_csh : string
|
||||
val env_hook_fish : string
|
||||
+val patch_shebangs : string
|
||||
diff --git a/src/state/shellscripts/patch_shebangs.sh b/src/state/shellscripts/patch_shebangs.sh
|
||||
new file mode 100755
|
||||
index 00000000..3ea84e2d
|
||||
--- /dev/null
|
||||
+++ b/src/state/shellscripts/patch_shebangs.sh
|
||||
@@ -0,0 +1,73 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# This setup hook causes the fixup phase to rewrite all script
|
||||
+# interpreter file names (`#! /path') to paths found in $PATH. E.g.,
|
||||
+# /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh.
|
||||
+# /usr/bin/env gets special treatment so that ".../bin/env python" is
|
||||
+# rewritten to /nix/store/<hash>/bin/python. Interpreters that are
|
||||
+# already in the store are left untouched.
|
||||
+
|
||||
+header() { echo "$1"; }
|
||||
+stopNest() { true; }
|
||||
+
|
||||
+fixupOutputHooks+=('if [ -z "${dontPatchShebangs-}" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi')
|
||||
+
|
||||
+patchShebangs() {
|
||||
+ local dir="$1"
|
||||
+ header "patching script interpreter paths in $dir"
|
||||
+ local f
|
||||
+ local oldPath
|
||||
+ local newPath
|
||||
+ local arg0
|
||||
+ local args
|
||||
+ local oldInterpreterLine
|
||||
+ local newInterpreterLine
|
||||
+
|
||||
+ find "$dir" -type f -perm -0100 | while read f; do
|
||||
+ if [ "$(head -1 "$f" | head -c+2)" != '#!' ]; then
|
||||
+ # missing shebang => not a script
|
||||
+ continue
|
||||
+ fi
|
||||
+
|
||||
+ oldInterpreterLine=$(head -1 "$f" | tail -c+3)
|
||||
+ read -r oldPath arg0 args <<< "$oldInterpreterLine"
|
||||
+
|
||||
+ if $(echo "$oldPath" | grep -q "/bin/env$"); then
|
||||
+ # Check for unsupported 'env' functionality:
|
||||
+ # - options: something starting with a '-'
|
||||
+ # - environment variables: foo=bar
|
||||
+ if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then
|
||||
+ echo "unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ newPath="$(command -v "$arg0" || true)"
|
||||
+ else
|
||||
+ if [ "$oldPath" = "" ]; then
|
||||
+ # If no interpreter is specified linux will use /bin/sh. Set
|
||||
+ # oldpath="/bin/sh" so that we get /nix/store/.../sh.
|
||||
+ oldPath="/bin/sh"
|
||||
+ fi
|
||||
+ newPath="$(command -v "$(basename "$oldPath")" || true)"
|
||||
+ args="$arg0 $args"
|
||||
+ fi
|
||||
+
|
||||
+ # Strip trailing whitespace introduced when no arguments are present
|
||||
+ newInterpreterLine="$(echo "$newPath $args" | sed 's/[[:space:]]*$//')"
|
||||
+
|
||||
+ if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then
|
||||
+ if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then
|
||||
+ echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
|
||||
+ # escape the escape chars so that sed doesn't interpret them
|
||||
+ escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
|
||||
+ # Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
|
||||
+ touch -r "$f" "$f.timestamp"
|
||||
+ sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
||||
+ touch -r "$f.timestamp" "$f"
|
||||
+ rm "$f.timestamp"
|
||||
+ fi
|
||||
+ fi
|
||||
+ done
|
||||
+
|
||||
+ stopNest
|
||||
+}
|
||||
+
|
||||
+patchShebangs .
|
||||
132
pkgs/development/tools/ocaml/opam/opam.nix.pl
Executable file
132
pkgs/development/tools/ocaml/opam/opam.nix.pl
Executable file
|
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings qw<all>;
|
||||
use Getopt::Std;
|
||||
|
||||
my $gencmd = "# Generated by: " . join(" ", $0, @ARGV) . "\n";
|
||||
|
||||
our $opt_v;
|
||||
our $opt_p;
|
||||
our $opt_r;
|
||||
our $opt_t;
|
||||
getopts "v:p:t:r:";
|
||||
|
||||
my $OPAM_RELEASE = $opt_v // "2.0.0";
|
||||
my $OPAM_TAG = $opt_t // $OPAM_RELEASE;
|
||||
my $OPAM_GITHUB_REPO = $opt_r // "ocaml/opam";
|
||||
my $OPAM_RELEASE_URL = "https://github.com/$OPAM_GITHUB_REPO/archive/$OPAM_TAG.zip";
|
||||
my $OPAM_RELEASE_SHA256 = `nix-prefetch-url \Q$OPAM_RELEASE_URL\E`;
|
||||
chomp $OPAM_RELEASE_SHA256;
|
||||
|
||||
my $OPAM_BASE_URL = "https://raw.githubusercontent.com/$OPAM_GITHUB_REPO/$OPAM_TAG";
|
||||
my $OPAM_OPAM = `curl -L --url \Q$OPAM_BASE_URL\E/opam-devel.opam`;
|
||||
my($OCAML_MIN_VERSION) = $OPAM_OPAM =~ /^ "ocaml" {>= "(.*)"}$/m
|
||||
or die "could not parse ocaml version bound\n";
|
||||
|
||||
print <<"EOF";
|
||||
{ stdenv, lib, fetchurl, makeWrapper, getconf,
|
||||
ocaml, unzip, ncurses, curl, aspcud, bubblewrap
|
||||
}:
|
||||
|
||||
assert lib.versionAtLeast ocaml.version "$OCAML_MIN_VERSION";
|
||||
|
||||
let
|
||||
srcs = {
|
||||
EOF
|
||||
|
||||
my %urls = ();
|
||||
my %md5s = ();
|
||||
|
||||
open(SOURCES, "-|", "curl", "-L", "--url", "$OPAM_BASE_URL/src_ext/Makefile.sources");
|
||||
while (<SOURCES>) {
|
||||
if (/^URL_(?!PKG_)([-\w]+)\s*=\s*(\S+)$/) {
|
||||
$urls{$1} = $2;
|
||||
} elsif (/^MD5_(?!PKG_)([-\w]+)\s*=\s*(\S+)$/) {
|
||||
$md5s{$1} = $2;
|
||||
}
|
||||
}
|
||||
for my $src (sort keys %urls) {
|
||||
my ($sha256,$store_path) = split /\n/, `nix-prefetch-url --print-path \Q$urls{$src}\E`;
|
||||
system "echo \Q$md5s{$src}\E' *'\Q$store_path\E | md5sum -c 1>&2";
|
||||
die "md5 check failed for $urls{$src}\n" if $?;
|
||||
print <<"EOF";
|
||||
"$src" = fetchurl {
|
||||
url = "$urls{$src}";
|
||||
sha256 = "$sha256";
|
||||
};
|
||||
EOF
|
||||
}
|
||||
|
||||
print <<"EOF";
|
||||
opam = fetchurl {
|
||||
url = "$OPAM_RELEASE_URL";
|
||||
sha256 = "$OPAM_RELEASE_SHA256";
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation {
|
||||
pname = "opam";
|
||||
version = "$OPAM_RELEASE";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
buildInputs = [ curl ncurses ocaml getconf ] ++ lib.optional stdenv.isLinux bubblewrap;
|
||||
|
||||
src = srcs.opam;
|
||||
|
||||
postUnpack = ''
|
||||
EOF
|
||||
for my $src (sort keys %urls) {
|
||||
my($ext) = $urls{$src} =~ /(\.(?:t(?:ar\.|)|)(?:gz|bz2?))$/
|
||||
or die "could not find extension for $urls{$src}\n";
|
||||
print <<"EOF";
|
||||
ln -sv \${srcs."$src"} \$sourceRoot/src_ext/$src$ext
|
||||
EOF
|
||||
}
|
||||
print <<'EOF';
|
||||
'';
|
||||
|
||||
EOF
|
||||
if (defined $opt_p) {
|
||||
print " patches = [ ";
|
||||
for my $patch (split /[, ]/, $opt_p) {
|
||||
$patch =~ s/^(?=[^\/]*$)/.\//;
|
||||
print "$patch ";
|
||||
}
|
||||
print "];\n\n";
|
||||
}
|
||||
print <<'EOF';
|
||||
preConfigure = ''
|
||||
substituteInPlace ./src_ext/Makefile --replace "%.stamp: %.download" "%.stamp:"
|
||||
patchShebangs src/state/shellscripts
|
||||
'';
|
||||
|
||||
postConfigure = "make lib-ext";
|
||||
|
||||
# Dirty, but apparently ocp-build requires a TERM
|
||||
makeFlags = ["TERM=screen"];
|
||||
|
||||
outputs = [ "out" "installer" ];
|
||||
setOutputFlags = false;
|
||||
|
||||
# change argv0 to "opam" as a workaround for
|
||||
# https://github.com/ocaml/opam/issues/2142
|
||||
postInstall = ''
|
||||
mv $out/bin/opam $out/bin/.opam-wrapped
|
||||
makeWrapper $out/bin/.opam-wrapped $out/bin/opam \
|
||||
--argv0 "opam" \
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin:${lib.optionalString stdenv.isLinux "${bubblewrap}/bin:"}${getconf}/bin \
|
||||
--set OPAM_USER_PATH_RO /run/current-system/sw/bin:/nix/
|
||||
$out/bin/opam-installer --prefix=$installer opam-installer.install
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "A package manager for OCaml";
|
||||
homepage = "https://opam.ocaml.org/";
|
||||
maintainers = [ maintainers.henrytill maintainers.marsam ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
print $gencmd;
|
||||
Loading…
Add table
Add a link
Reference in a new issue