unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Packaging goldendict with support for optionally installed dictionaries
@ 2017-10-29  5:14 Brendan Tildesley
  2017-10-29 15:11 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Brendan Tildesley @ 2017-10-29  5:14 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1444 bytes --]

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.
libxt has a patch that hard codes the rule to check
/run/current-system/profile, and if GUIX_PROFILE exists, check that,
otherwise if HOME exists check $HOME/.guix-profile/...
That's the only solution I can see working unless anyone has a better
suggestion, I'd like to ask for some help writing the patch though since
I've never written any C/C++ before, I was stuck figuring out how to
define a string :(.

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.



[-- Attachment #2: Type: text/html, Size: 2032 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Packaging goldendict with support for optionally installed dictionaries
  2017-10-29  5:14 Packaging goldendict with support for optionally installed dictionaries Brendan Tildesley
@ 2017-10-29 15:11 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2017-10-29 15:11 UTC (permalink / raw)
  To: Brendan Tildesley; +Cc: guix-devel

Hi Brendan,

Brendan Tildesley <brendan.tildesley@openmailbox.org> 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’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-29 15:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-29  5:14 Packaging goldendict with support for optionally installed dictionaries Brendan Tildesley
2017-10-29 15:11 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).