diff options
-rwxr-xr-x | vendor/gen-vendor.py | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/vendor/gen-vendor.py b/vendor/gen-vendor.py deleted file mode 100755 index a38da61..0000000 --- a/vendor/gen-vendor.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -import subprocess -from os.path import exists -import re - -# tee the output of the given command -def run(cmd): - proc = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, encoding='utf-8') - - outp = "" - while proc.poll() is None: - line = proc.stdout.readline() - if line: - print(line.strip()) - outp += line - return outp - -pkgs = run(["raco", "pkg", "show", "-a", "--scope" ,"user"]).split("\n") -catalog_pkg_names = [l.split(" ")[0].replace("*", "") for l in pkgs if "catalog" in l] - -print("Found %d packages" % len(catalog_pkg_names)) - -infos = [] -for pkg in catalog_pkg_names: - info = run(["raco", "pkg", "catalog-show", pkg]) - m = re.search(r'Source: (.*)', info) - url = m.group(1) - fname = url.split("/")[-1] - if not exists(fname): - run(["curl", "-OL", url]) - infos.append((pkg, url, run(["nix", "hash", "file", fname]).strip())) - -# fetch files and install packages -configurePhase = "mkdir -p $out\n" + "\n".join([ - "raco pkg install --scope-dir $out -t dir -n %s --no-setup --deps force ${fetchurl { url = \"%s\"; hash = \"%s\"; }}" % (name, url, hash) - for (name, url, hash) in infos -]) - -# do building -buildPhase = "raco pkg install --scope-dir $out --skip-installed " + " ".join(catalog_pkg_names) - -with open("./default.nix", "w") as f: - f.write(""" -{pkgs ? import <nixpkgs> {}, ...}: let - inherit (pkgs) fetchurl; - collection = pkgs.stdenv.mkDerivation { - name = "raco-catalog"; - buildInputs = [pkgs.racket-minimal]; - dontUnpack = true; - - configurePhase = '' - %s - ''; - buildPhase = "%s"; - }; in - pkgs.stdenv.mkDerivation { - name = "racket-wrapped"; - installPhase = '' - mkdir -p $out/bin - ln -s $out/pkgs ${collection}; - mkWrapper ${pkgs.racket-minimal}/bin/racket \ - $out/bin/racket \ - --set PLTADDONDIR $out/pkgs; - ''; - } - """ % (configurePhase, buildPhase)) |