Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load libraries from central location #2804

Open
nomeata opened this issue Oct 14, 2017 · 6 comments
Open

Load libraries from central location #2804

nomeata opened this issue Oct 14, 2017 · 6 comments
Labels
status: info-needed More information is needed from the bug reporter to confirm the issue. type: enhancement Issues and pull requests about possible improvements ux: library management Issues relating to the library management system ux: packaging Distribution of, and packaging of, Agda itself
Milestone

Comments

@nomeata
Copy link

nomeata commented Oct 14, 2017

Debian packages agda and agda-stdlib. Ideally, once you run

apt install agda

you should be able to run agda -l standard-library Foo.agda.

For this to be working, agda needs to be able to look for .agda-lib files in a well-known system-wide location.

I propose (and actually have prepared the agda-stdlib package in Debian accordingly) to load all files named *.agda-lib in

/var/lib/agda

Of course other package management systems can benefit from this as well, and for example university pool rooms can setup agda this way so that users don’t have to configure stuff in ~/.agda

@nomeata
Copy link
Author

nomeata commented Oct 14, 2017

Here is the patch I am using for now, feel free to use this or to implement it a better way:

Index: agda/src/full/Agda/Interaction/Library.hs
===================================================================
--- agda.orig/src/full/Agda/Interaction/Library.hs	2017-10-13 21:58:48.432139892 -0400
+++ agda/src/full/Agda/Interaction/Library.hs	2017-10-13 22:39:44.970695744 -0400
@@ -215,13 +215,20 @@
   -> LibM [AgdaLibFile] -- ^ Content of library files.  (Might have empty @LibName@s.)
 getInstalledLibraries overrideLibFile = mkLibM [] $ do
     file <- lift $ getLibrariesFile overrideLibFile
-    ifNotM (lift $ doesFileExist file) (return []) $ {-else-} do
+    userlibs <- ifNotM (lift $ doesFileExist file) (return []) $ {-else-} do
       ls    <- lift $ stripCommentLines <$> readFile file
       files <- lift $ sequence [ (i, ) <$> expandEnvironmentVariables s | (i, s) <- ls ]
       parseLibFiles (Just file) files
+
+    systemlibs <- ifNotM (lift $ doesDirectoryExist systemLibDir) (return []) $ do
+      files <- lift $ filter isLibFile <$> listDirectory systemLibDir
+      parseLibFiles Nothing $ zip [1..] $ map (systemLibDir </>) files
+    return $ userlibs ++ systemlibs
   `catchIO` \ e -> do
     tell [ OtherError $ unlines ["Failed to read installed libraries.", show e] ]
     return []
+  where systemLibDir = "/var/lib/agda"
+        isLibFile fn = takeExtension fn == ".agda-lib" && not ("." `List.isPrefixOf` fn)
 
 -- | Parse the given library files.
 --

@andreasabel
Copy link
Member

Thanks! What would be suitable locations for Windows and Mac OS?

@nomeata
Copy link
Author

nomeata commented Oct 14, 2017

Sorry, not my field of expertise. Whoever creates ready-to-use packages of the standard library for these systems might have an opinion (homebrew etc.).

@gallais gallais added ux: library management Issues relating to the library management system ux: packaging Distribution of, and packaging of, Agda itself labels Oct 17, 2017
@nad
Copy link
Contributor

nad commented Oct 17, 2017

None of the predefined directories in System.Directory seem to match. Perhaps we can have a list of system directories, and let the list be empty by default. Replacing this list with something suitable is then presumably easy for those who package Agda.

If such a list is added, then I think that it should be possible to override or ignore it by using command line options.

@UlfNorell
Copy link
Member

I'm not sure I understand exactly what you are doing here. At the moment you "install" a library by adding the path to its .agda-lib file to your libraries file (typically in ~/.agda).

With your change it looks like you should copy the .agda-lib file to the /var/lib/agda directory? How does this work with include paths? For example, the standard library library file says include: src, do you have to change that to an absolute path when copying it?

Wouldn't it make more sense to load /var/lib/agda/*/*.agda-lib, having the entire library live under /var/lib/agda?

@UlfNorell UlfNorell added this to the 2.5.5 milestone Jun 1, 2018
@UlfNorell UlfNorell added status: info-needed More information is needed from the bug reporter to confirm the issue. type: enhancement Issues and pull requests about possible improvements labels Jun 1, 2018
@nomeata
Copy link
Author

nomeata commented Jun 1, 2018

Hmm, I don’t remember all my thoughts from back then, but yeah, I think the plan was for the package maintainer to adjust the include path to be absolute when a library is installed via a system package.

Wouldn't it make more sense to load /var/lib/agda//.agda-lib, having the entire library live under /var/lib/agda?

That would work as well!

@jespercockx jespercockx modified the milestones: 2.6.0, 2.6.1 Nov 15, 2018
@jespercockx jespercockx modified the milestones: 2.6.1, 2.6.2 Oct 8, 2019
@jespercockx jespercockx modified the milestones: 2.6.2, icebox Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: info-needed More information is needed from the bug reporter to confirm the issue. type: enhancement Issues and pull requests about possible improvements ux: library management Issues relating to the library management system ux: packaging Distribution of, and packaging of, Agda itself
Projects
None yet
Development

No branches or pull requests

6 participants