diff --git a/asdf-nix.patch b/asdf-nix.patch index 000f9b4..8e8d2c6 100644 --- a/asdf-nix.patch +++ b/asdf-nix.patch @@ -1,8 +1,6 @@ -diff --git a/output-translations.lisp b/output-translations.lisp -index d2512ba0..af750f38 100644 --- a/output-translations.lisp +++ b/output-translations.lisp -@@ -146,6 +146,7 @@ and the order is by decreasing length of namestring of the source pathname.") +@@ -146,6 +146,7 @@ '(environment-output-translations user-output-translations-pathname user-output-translations-directory-pathname @@ -10,7 +8,7 @@ index d2512ba0..af750f38 100644 system-output-translations-pathname system-output-translations-directory-pathname)) -@@ -184,6 +185,14 @@ and the order is by decreasing length of namestring of the source pathname.") +@@ -184,6 +185,14 @@ :direction direction)) (defun environment-output-translations () (getenv "ASDF_OUTPUT_TRANSLATIONS")) @@ -18,18 +16,17 @@ index d2512ba0..af750f38 100644 + `(:output-translations + ,@(loop :for profile :in (reverse (split-string (or (getenv "NIX_PROFILES") ""))) + :for share := (subpathname (ensure-directory-pathname profile) "share/") -+ :for conf := (subpathname share *output-translations-directory*) -+ :when (probe-file* conf) -+ :collect `(:include ,conf)) ++ :for sysdir := (namestring (subpathname share "common-lisp/systems/")) ++ :for fasldir := (namestring (subpathname share "common-lisp/fasl/")) ++ :collect `(,sysdir (,fasldir :implementation))) + :inherit-configuration)) ;;; Processing the configuration. -diff --git a/source-registry.lisp b/source-registry.lisp -index a086cc88..cc317591 100644 + --- a/source-registry.lisp +++ b/source-registry.lisp -@@ -187,6 +187,7 @@ after having found a .asd file? True by default.") +@@ -187,6 +187,7 @@ user-source-registry user-source-registry-directory default-user-source-registry @@ -37,7 +34,7 @@ index a086cc88..cc317591 100644 system-source-registry system-source-registry-directory default-system-source-registry) -@@ -227,6 +228,14 @@ after having found a .asd file? True by default.") +@@ -227,5 +228,11 @@ :direction direction)) (defun environment-source-registry () (getenv "CL_SOURCE_REGISTRY")) @@ -45,10 +42,8 @@ index a086cc88..cc317591 100644 + `(:source-registry + ,@(loop :for profile :in (reverse (split-string (or (getenv "NIX_PROFILES") ""))) + :for share := (subpathname (ensure-directory-pathname profile) "share/") -+ :for conf := (subpathname share *source-registry-directory*) -+ :when (probe-file* conf) -+ :collect `(:include ,conf)) ++ :collect `(:tree ,(namestring (subpathname share (parse-unix-namestring "common-lisp/systems/"))))) + :inherit-configuration)) - ;;; Process the source-registry configuration + ;;; Process the source-registry configuration \ No newline at end of file diff --git a/builder.lisp b/builder.lisp index 16bd563..e129ed7 100644 --- a/builder.lisp +++ b/builder.lisp @@ -13,15 +13,20 @@ ;; "user cache" via an additional runtime output translation configuration. (defvar *pwd* (namestring (uiop:getcwd))) +(defvar *src* (namestring (uiop:getenv "src"))) +(defvar *out* (namestring (uiop:getenv "out"))) +(defvar *pname* (format nil "~a/" (uiop:getenv "pname"))) +(setf asdf:*resolve-symlinks* nil) (asdf:initialize-source-registry - `(:source-registry :inherit-configuration (:tree ,*pwd*))) + `(:source-registry :inherit-configuration (:tree ,*src*))) + (asdf:initialize-output-translations `(:output-translations :disable-cache ("/nix/store/" "/nix/store/") - (,*pwd* (,*pwd* "__tmpfasl__")) + (,*src* (,*out* "share" "common-lisp" "fasl" :implementation ,*pname*)) :inherit-configuration)) (defvar *declared-systems* (uiop:split-string (uiop:getenv "systems"))) @@ -36,12 +41,16 @@ ;; (defmethod asdf:operate :before (o c &key) ;; (format t "[INFO] Checking... ~A ~A ~A ~A~%" o c *system* (asdf:output-files o c))) -(defvar *out* (uiop:getenv "out")) (defun out-path-p (path) (or (uiop:string-prefix-p *pwd* (namestring path)) (uiop:string-prefix-p *out* (namestring path)))) +(defmethod asdf:perform :before ((o asdf:prepare-op) (c asdf:file-component)) + (let ((path (asdf:component-relative-pathname c)) + (path2 (asdf:component-pathname c))) + (format t "FOOOOOOO: ~A >>> ~A~%" path path2))) + (defmethod asdf:perform :before ((o asdf:compile-op) (c asdf:source-file)) (let ((out (asdf:output-files o c))) (format t "[INFO] [OUT] Checking... ~A ~A ~A ~A~%" o c *system* out) diff --git a/nix-cl.nix b/nix-cl.nix index 02ce0d1..c7dc5ce 100644 --- a/nix-cl.nix +++ b/nix-cl.nix @@ -212,28 +212,6 @@ let concatMapStringsSep "\\|" (replaceStrings ["." "+"] ["[.]" "[+]"]) systems; in '' - cat < $out/share/common-lisp/asdf-output-translations.conf.d/10-${pname}.conf < $out/share/common-lisp/source-registry.conf.d/10-${pname}.conf < $out/share/common-lisp/systems/${pname}/.cl-source-registry.cache - (:source-registry-cache $asds) - EOF ''; dontPatchShebangs = true; @@ -262,10 +234,20 @@ let setupHook = ./setup-hook.sh; } // (args // rec { - src = if builtins.length (args.patches or []) > 0 - then pkgs.applyPatches { inherit (args) src patches; } - else args.src; + src = pkgs.applyPatches { + inherit (args) src; + systems = args.systems or [ args.pname ]; + patches = args.patches or []; + postPatch = '' + declare -a asds=() + for s in $systems; do + asds+="\"$(find -name $s.asd -type f -print -quit)\"" + done + echo "(:source-registry-cache ''${asds[@]})" > .cl-source-registry.cache + '' + args.postPatch or ""; + }; patches = []; + postPatch = ""; propagatedBuildInputs = args.propagatedBuildInputs or [] ++ lispLibs ++ javaLibs ++ nativeLibs; propagatedUserEnvPkgs = propagatedBuildInputs; @@ -324,7 +306,7 @@ let --add-flags "${o.flags}" \ --set ASDF "${o.asdfFasl}" \ --prefix CL_SOURCE_REGISTRY : "$CL_SOURCE_REGISTRY" \ - --prefix ASDF_OUTPUT_TRANSLATIONS : "$(echo $CL_SOURCE_REGISTRY | sed s,//:,::,g):" \ + --prefix ASDF_OUTPUT_TRANSLATIONS : "$ASDF_OUTPUT_TRANSLATIONS" \ --prefix LD_LIBRARY_PATH : "$LD_LIBRARY_PATH" \ --prefix DYLD_LIBRARY_PATH : "$DYLD_LIBRARY_PATH" \ --prefix CLASSPATH : "$CLASSPATH" \ diff --git a/setup-hook.sh b/setup-hook.sh index 0f162a4..15c2b2a 100644 --- a/setup-hook.sh +++ b/setup-hook.sh @@ -6,24 +6,15 @@ # How about nix-shell/dev shell? Is it fine to create files there, somewhere like /tmp? addAsdfSourceRegistry () { - if test -z "${CL_SOURCE_REGISTRY:-}"; then - export CL_SOURCE_REGISTRY="(:source-registry :ignore-inherited-configuration)" - fi - if test -d "$1/share/common-lisp/source-registry.conf.d/"; then - if [[ ! "$CL_SOURCE_REGISTRY" =~ "$1/share/common-lisp/source-registry.conf.d/" ]]; then - export CL_SOURCE_REGISTRY="(:source-registry :ignore-inherited-configuration (:include \"$1/share/common-lisp/source-registry.conf.d/\")${CL_SOURCE_REGISTRY:49}" - fi + if test -d "$1/share/common-lisp"; then + addToSearchPath CL_SOURCE_REGISTRY "$1/share/common-lisp/systems//" fi } addAsdfOutputTranslation () { - if test -z "${ASDF_OUTPUT_TRANSLATIONS:-}"; then - export ASDF_OUTPUT_TRANSLATIONS="(:output-translations :ignore-inherited-configuration)" - fi - if test -d "$1/share/common-lisp/asdf-output-translations.conf.d/"; then - if [[ ! "$ASDF_OUTPUT_TRANSLATIONS" =~ "$1/share/common-lisp/asdf-output-translations.conf.d/" ]]; then - export ASDF_OUTPUT_TRANSLATIONS="(:output-translations :ignore-inherited-configuration (:include \"$1/share/common-lisp/asdf-output-translations.conf.d/\")${ASDF_OUTPUT_TRANSLATIONS:53}" - fi + if test -d "$1/share/common-lisp"; then + addToSearchPath ASDF_OUTPUT_TRANSLATIONS "$1/share/common-lisp/systems/" + addToSearchPath ASDF_OUTPUT_TRANSLATIONS "$(find $1/share/common-lisp/fasl/ -mindepth 1 -maxdepth 1 -print -quit)/" fi }