all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Josselin Poiret via Guix-patches via <guix-patches@gnu.org>
To: Josselin Poiret <dev@jpoiret.xyz>,
	Simon Tournier <zimon.toutoune@gmail.com>,
	61915@debbugs.gnu.org
Subject: [bug#61915] [PATCH v2 07/13] gnu: agda: Add AGDA_LIBDIRS search-path.
Date: Sun, 30 Apr 2023 12:53:17 +0200	[thread overview]
Message-ID: <7d567a3e6da787aa9757c0f265469393dde01833.1682851600.git.dev@jpoiret.xyz> (raw)
In-Reply-To: <cover.1682851600.git.dev@jpoiret.xyz>

From: Josselin Poiret <dev@jpoiret.xyz>

* gnu/packages/patches/agda-libdirs-env-variable.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/agda.scm (agda): Patch agda, and add search path.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/agda.scm                         | 10 +++-
 .../patches/agda-libdirs-env-variable.patch   | 49 +++++++++++++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/agda-libdirs-env-variable.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 1a84e5b499..712649c5fc 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -880,6 +880,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/aegisub-icu59-include-unistr.patch	\
   %D%/packages/patches/aegisub-boost68.patch			\
   %D%/packages/patches/aegisub-make43.patch			\
+  %D%/packages/patches/agda-libdirs-env-variable.patch	\
   %D%/packages/patches/agg-am_c_prototype.patch			\
   %D%/packages/patches/agg-2.5-gcc8.patch			\
   %D%/packages/patches/akonadi-paths.patch		\
diff --git a/gnu/packages/agda.scm b/gnu/packages/agda.scm
index d94036939c..17ea5b62be 100644
--- a/gnu/packages/agda.scm
+++ b/gnu/packages/agda.scm
@@ -22,6 +22,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages agda)
+  #:use-module (gnu packages)
   #:use-module (gnu packages haskell-check)
   #:use-module (gnu packages haskell-web)
   #:use-module (gnu packages haskell-xyz)
@@ -50,7 +51,8 @@ (define-public agda
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1s7zd01i8pmvi90ywx497kc07z50nah7h0fc2dn6jzb132k5sh1q"))))
+        (base32 "1s7zd01i8pmvi90ywx497kc07z50nah7h0fc2dn6jzb132k5sh1q"))
+       (patches (search-patches "agda-libdirs-env-variable.patch"))))
     (build-system haskell-build-system)
     (inputs
      (list ghc-aeson
@@ -108,6 +110,12 @@ (define-public agda
                        (setenv "infodir" (string-append #$output
                                                         "/share/info"))
                        (invoke "make" "install-info"))))))))
+    (search-paths
+     (list (search-path-specification
+            (variable "AGDA_LIBDIRS")
+            (files (list "lib/agda")))))
+    (native-search-paths
+     search-paths)
     (home-page "https://wiki.portal.chalmers.se/agda/")
     (synopsis
      "Dependently typed functional programming language and proof assistant")
diff --git a/gnu/packages/patches/agda-libdirs-env-variable.patch b/gnu/packages/patches/agda-libdirs-env-variable.patch
new file mode 100644
index 0000000000..3b291358a6
--- /dev/null
+++ b/gnu/packages/patches/agda-libdirs-env-variable.patch
@@ -0,0 +1,49 @@
+From 457bc7438a4f0801dbf332fa2369248bddf5da0c Mon Sep 17 00:00:00 2001
+Message-Id: <457bc7438a4f0801dbf332fa2369248bddf5da0c.1678309546.git.dev@jpoiret.xyz>
+From: Josselin Poiret <dev@jpoiret.xyz>
+Date: Wed, 8 Mar 2023 18:31:52 +0100
+Subject: [PATCH] Add environment variable for library directories
+
+AGDA_LIBDIRS is a new environment colon-separated variable for site libraries.
+Agda will look for .agda-lib files directly inside direct descendants of these.
+---
+ src/full/Agda/Interaction/Library.hs | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/src/full/Agda/Interaction/Library.hs b/src/full/Agda/Interaction/Library.hs
+index 09c1f2a82..774cc3e74 100644
+--- a/src/full/Agda/Interaction/Library.hs
++++ b/src/full/Agda/Interaction/Library.hs
+@@ -323,13 +323,25 @@ getInstalledLibraries overrideLibFile = mkLibM [] $ do
+         raiseErrors' [ LibrariesFileNotFound theOverrideLibFile ]
+         return []
+       Right file -> do
+-        if not (lfExists file) then return [] else do
++        siteLibDirs <- liftIO $ fromMaybe [] . fmap splitAtColon . lookup "AGDA_LIBDIRS" <$> getEnvironment
++        siteLibs <- liftIO $ concat <$> mapM findSiteLibs siteLibDirs
++        if not (lfExists file) then parseLibFiles Nothing $ nubOn snd ((0,) <$> siteLibs) else do
+           ls    <- liftIO $ stripCommentLines <$> UTF8.readFile (lfPath file)
+           files <- liftIO $ sequence [ (i, ) <$> expandEnvironmentVariables s | (i, s) <- ls ]
+-          parseLibFiles (Just file) $ nubOn snd files
++          parseLibFiles (Just file) $ nubOn snd (files ++ fmap (0,) siteLibs)
+   `catchIO` \ e -> do
+     raiseErrors' [ ReadError e "Failed to read installed libraries." ]
+     return []
++  where splitAtColon :: String -> [String]
++        splitAtColon "" = []
++        splitAtColon str = case break (==':') str of
++          (a, _:b) -> a : splitAtColon b
++          (a, "")    -> [a]
++        findSiteLibs :: String -> IO [String]
++        findSiteLibs dir = do
++          subDirs <- filterM doesDirectoryExist =<< map (dir </>) <$> listDirectory dir
++          subFiles <- mapM (\dir -> map (dir </>) <$> listDirectory dir) subDirs
++          return $ concatMap (filter (List.isSuffixOf ".agda-lib")) subFiles
+ 
+ -- | Parse the given library files.
+ --
+
+base-commit: 183534bc41af5a53daf685122997dc98883f2be2
+-- 
+2.39.1
+
-- 
2.39.2





  parent reply	other threads:[~2023-04-30 11:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 14:10 [bug#61915] [PATCH 0/4] Update Agda to 2.6.3 Josselin Poiret via Guix-patches via
2023-03-02 14:13 ` [bug#61915] [PATCH 1/4] gnu: Add ghc-peano Josselin Poiret via Guix-patches via
2023-03-02 14:13 ` [bug#61915] [PATCH 2/4] gnu: Add ghc-vector-hashtables Josselin Poiret via Guix-patches via
2023-03-02 14:13 ` [bug#61915] [PATCH 3/4] gnu: agda: Update to 2.6.3 and switch to git-fetch Josselin Poiret via Guix-patches via
2023-03-02 14:13 ` [bug#61915] [PATCH 4/4] gnu: agda: Build info manual Josselin Poiret via Guix-patches via
2023-03-03  1:30 ` [bug#61915] [PATCH 0/4] Update Agda to 2.6.3 Simon Tournier
2023-03-03 16:24   ` Josselin Poiret via Guix-patches via
2023-04-30 10:53     ` [bug#61915] [PATCH v2 00/13] Update agda, add build-system and libraries Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 01/13] gnu: Add ghc-peano Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 02/13] gnu: Add ghc-vector-hashtables Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 03/13] gnu: agda: Update to 2.6.3 and switch to git-fetch Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 04/13] gnu: agda: Build info manual Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 05/13] gnu: emacs-agda2-mode: No longer inherit from agda Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 06/13] gnu: emacs-agda2-mode: Switch to G-Exps Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` Josselin Poiret via Guix-patches via [this message]
2023-04-30 10:53       ` [bug#61915] [PATCH v2 08/13] build-system/haskell: Export default-haskell Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 09/13] build-system: New agda-build-system Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 10/13] gnu: Add agda-stdlib Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 11/13] gnu: Add agda-categories Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 12/13] gnu: Add agda-cubical Josselin Poiret via Guix-patches via
2023-04-30 10:53       ` [bug#61915] [PATCH v2 13/13] gnu: Add agda-1lab Josselin Poiret via Guix-patches via
2023-06-04  9:47       ` bug#61915: [PATCH v2 00/13] Update agda, add build-system and libraries Josselin Poiret via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d567a3e6da787aa9757c0f265469393dde01833.1682851600.git.dev@jpoiret.xyz \
    --to=guix-patches@gnu.org \
    --cc=61915@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.