guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Packaging goldendict with support for optionally installed dictionar


From: Ludovic Courtès
Subject: Re: Packaging goldendict with support for optionally installed dictionaries
Date: Sun, 29 Oct 2017 16:11:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hi Brendan,

Brendan Tildesley <address@hidden> skribis:

> I'm working on packaging goldendict, a dictionary reader, along with
> many free dictionaries in various languages. This essentially requires
> "optional dependencies", a concept alien to Guix's functional model.
> However some by default goldendict checks directories such as
> /usr/share/stardict/dicfor dictionaries, but Guix has 2 other locations
> dictionaries may be found; /run/current-system/profile/share/..., and
> $GUIX_PROFILE/share/...
> A couple packages like ibus and aspell solve this using
> 'native-search-paths' which seems to require the program to have an
> environment variable it checks for search paths, which goldendict
> doesn't. There isn't much documentation on native-search-paths so I
> don't know what it actually does.

‘native-search-paths’ defines search path environment variables that the
package honors.  The following example illustrates what happens with
Aspell.  If I install aspell alone, I get no mention of ASPELL_DICT_DIR:

--8<---------------cut here---------------start------------->8---
$ guix package -p foo -i aspell
The following package will be installed:
   aspell       0.60.6.1        
/gnu/store/7idvqhyk25q6pf6k25dwp43hnjgl9rbp-aspell-0.60.6.1

1 package in profile
The following environment variable definitions may be needed:
   export PATH="foo/bin${PATH:+:}$PATH"
--8<---------------cut here---------------end--------------->8---

Now, if I install it alongside a dictionary package, which provides a
“lib/aspell” sub-directory, then the tool tells me about
ASPELL_DICT_DIR:

--8<---------------cut here---------------start------------->8---
$ guix package -p foo -i aspell aspell-dict-fr
The following package will be upgraded:
   aspell       0.60.6.1 → 0.60.6.1     
/gnu/store/7idvqhyk25q6pf6k25dwp43hnjgl9rbp-aspell-0.60.6.1

The following package will be installed:
   aspell-dict-fr       0.50-3  
/gnu/store/jrwkvybb6j9wygas3j9ir0fjhcz9dkpx-aspell-dict-fr-0.50-3

substitute: updating list of substitutes from 'https://berlin.guixsd.org'... 
100.0%
substitute: updating list of substitutes from 'https://mirror.hydra.gnu.org'... 
100.0%
The following derivations will be built:
   /gnu/store/q3vb8hy6zw42w4zc8hy0k3c2z7nhgbpy-profile.drv
   /gnu/store/hr2hz96la7m082cy8fz93350pks2hiaa-info-dir.drv
   /gnu/store/gf9mi699x2v3rrw7h2igz867jxky3wy6-ca-certificate-bundle.drv
   /gnu/store/7ifj4snydf5lk4xkkply7435fp4wy7sw-fonts-dir.drv
   /gnu/store/bmv23cajajffn9lv5kzfzg8i1l2x2m1w-manual-database.drv
Creating manual page database for 1 packages... done in 0.126 s
2 packages in profile
The following environment variable definitions may be needed:
   export PATH="foo/bin${PATH:+:}$PATH"
   export ASPELL_DICT_DIR="foo/lib/aspell"
--8<---------------cut here---------------end--------------->8---

See also the documentation of ‘--search-paths’:

  https://www.gnu.org/software/guix/manual/html_node/Invoking-guix-package.html

I hope this clarifies things.

> I think it can be done by making a copy of this code block and wrapping
> it in the above logic:
> https://github.com/goldendict/goldendict/blob/master/config.cc#L335
> It would be good to keep the original /usr/share search paths so that
> goldendict will interoperate if guix is installed on a foreign distro.

I would recommend first searching for calls to ‘getenv’ (or similar) in
the source of goldendict.

If it turns out that all it does is look at these hard-coded /usr/share
directories in config.cc, then I would prepare a patch that (1) removes
all these /usr/share references in config.cc, and (2) does something
like (untested!):

  const char *dictionary_dir = getenv ("GOLDENDICT_DICTIONARY_DIRECTORY");
  if (dictionary_dir != NULL && QDir (dictionary_dir).exists ())
    c_paths.push_back (Path(dictionary_dir), true);

(Better yet would be to support a colon-separated dictionary search
path.)

We can then use it right away in Guix, but I strongly encourage you to
submit it upstream as well because the problem it’s solving is not
Guix-specific.

HTH!

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]