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

aspell: added new patch data-dirs-from-nix-profiles.patch #30234

Merged
merged 1 commit into from Oct 23, 2017

Conversation

roastiek
Copy link
Contributor

@roastiek roastiek commented Oct 8, 2017

Aspell will search for dictionaries in all nix profiles even when used as library.
Setting data-dir or dict-dir in ASPELL_CONF will disable this behavior.

Motivation for this change

The ASPELL_CONF variable is used only by aspell binary so any application using aspell API will never see any dictionaries (like in #28815). Internal code of aspell allows multiple data/dict search paths so is possible to add all lib/aspell subdirectories from all nix profiles, unlike when using ASPELL_CONF.
Any application using libaspell will be able use any dictionary installed without any modification.

I have looked on aspellWithDicts derivation, but I don't think it could solve this problem.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@michalrus
Copy link
Member

@deedrah, how about this part?

unset ASPELL_CONF
for i in ${concatStringsSep " " (reverseList cfg.profiles)} ; do
if [ -d "$i/lib/aspell" ]; then
export ASPELL_CONF="dict-dir $i/lib/aspell"
fi
done

@michalrus
Copy link
Member

@deedrah, could you check languages list in gnome3.evolution as reported in #28815?

This PR doesn’t fix it for me. =( Still only Hebrew available there.

Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked on aspellWithDicts derivation, but I don't think it could solve this problem.

It may be good to add a line in the header of the aspellWithDicts expression explaining this limitation.

@@ -10,6 +10,7 @@ stdenv.mkDerivation rec {

patchPhase = ''
patch interfaces/cc/aspell.h < ${./clang.patch}
patch -p1 < ${./data-dirs-from-nix-profiles.patch}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be an optional patch, because looking for NIX_PROFILES is basically an impurity. See the if [ -z "\$ASPELL_CONF" ]; then in the code that is removed. This is important for aspellWithPackages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For build-time purity, I agree. For run-time purity, I think it's a bit of a gray area. Taking this purity argument to the extreme would be that e.g. "bash" on NixOS would not see "git" unless you have a "bash = bashWithPackages [ git ]" thing. And I don't think we want that :-)

An alternative could be to modify the patch so that it only reads NIX_PROFILES if NIX_ASPELL_USE_PROFILES is set (or something). Then the patch could be applied unconditionally. (No recompilation needed.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For build-time purity, I agree. For run-time purity, I think it's a bit of a gray area. Taking this purity argument to the extreme would be that e.g. "bash" on NixOS would not see "git" unless you have a "bash = bashWithPackages [ git ]" thing. And I don't think we want that :-)

That's an impurity that exists by default, and one which is quite useful. Yet, if you want to, you could prevent it by creating a buildEnv and creating wrappers setting e.g PATH.

In this case, the impurity can also be useful, however it is now forced, thus requiring a wrapper unsetting NIX_PROFILES.

If I wanted these kind of impurities, I could have stayed with Debian or any other distro.

Copy link
Contributor Author

@roastiek roastiek Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition ensure that whenever ASPELL_CONF contains data-dir or dict-dir, NIX_PROFILES is ignored.

I have tested that aspellWithDicts behaves as it should with this patch.

I don't think another variable is needed, but adding new parameter for the derivation like searchNixProfiles for safety would be OK.

@roastiek
Copy link
Contributor Author

roastiek commented Oct 9, 2017

@michalrus I have tested it with evolution from 17.03, not from this branch.

I have tried build gedit from this branch (it is faster). I have 'aspellDicts.cs' and 'aspellDicts.en' in 'systemPackages' and installed another dict via nix-env -iA nixos.aspellDicts.de and all of them where available (prefs -> tools -> set language).

And about nixpkgs/nixos/modules/programs/environment.nix, I am just not sure, if removing that code should be part of this PR. I think it is useless even with current aspell derivation and cloud be removed regardless whether this PR gets accepted or not.

@FRidh
Copy link
Member

FRidh commented Oct 9, 2017

how about this part?

I agree with @deedrah , that's for another PR.

@roastiek roastiek force-pushed the aspell-data-dirs-from-nix-profiles branch from f3859bf to 86c5bfc Compare October 11, 2017 17:03
@roastiek
Copy link
Contributor Author

I have update my branch.

@michalrus evolution sometimes keeps background running process and maybe the new binary was not used (maybe log out/in is needed). Could you test it with gedit? Or describe more detailed, how did you tried?

@michalrus
Copy link
Member

@deedrah, I think I just used:

$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/86c5bfcdc610b06d4c943de9438148cb422e528e.tar.gz -p gnome3.evolution

… but with the previous commit SHA1.

But now when I tried that, with the current one:

builder for ‘/nix/store/nqirmq896dyngcj4ir1c4x9pllcb3han-liboauth-1.0.3’ failed previously (cached)

The error was:

/nix/store/xmfz6cv13ippmg425rar74nygmlj06jl-bash-4.4-p12/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CON
FIG_H -I.    -Wall -I/nix/store/agdpcdar9fmjcd4cm3algmjzpxsa5bny-nss-3.32.1/include/nss -I/nix/store/smhc7vh4a57j08j9k
nrc73v6vpnybmj9-nspr-4.16-dev/include  -g -O2 -c -o liboauth_la-oauth.lo `test -f 'oauth.c' || echo './'`oauth.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -Wall -I/nix/store/agdpcdar9fmjcd4cm3algmjzpxsa5bny-nss-3.32.1/include/nss 
-I/nix/store/smhc7vh4a57j08j9knrc73v6vpnybmj9-nspr-4.16-dev/include -g -O2 -c oauth.c  -fPIC -DPIC -o .libs/liboauth_l
a-oauth.o

No such file or directory
 #  include "pk11pub.h"
                       ^
compilation terminated.
make[2]: *** [Makefile:377: liboauth_la-oauth.lo] Error 1

So this is unrelated to your PR. Could you give me a command that works for you w/ gedit?

Thank you for your effort! ♥

@michalrus
Copy link
Member

Possibly just rebase this commit onto somewhere later, where that pk11pub.h bug has been fixed. :)

@michalrus
Copy link
Member

This patch starts to compile on current nixos-unstable, 0ce09af.

But it’s currently building webkit. :/

@michalrus
Copy link
Member

michalrus commented Oct 22, 2017

It compiled well on nixos-unstable, however, when running, fails with:

The name org.gnome.evolution.dataserver.Sources5 was not provided by any .service files

I do confirm gedit works, though.

@michalrus
Copy link
Member

@deedrah, @FRidh, I managed to get it working, and the dictionaries are available.

Everything seems to be working fine. ✅

@michalrus
Copy link
Member

@deedrah, so it would be wonderful if you rebased this commit onto nixos-unstable, so that people can use this directly giving SHA1 to nix-shell, until it’s merged/discussed/etc. 🙏

Aspell will search for dictionaries in all nix profiles even when used as library.
Setting data-dir or dict-dir in ASPELL_CONF will disable this behavior.
@roastiek roastiek force-pushed the aspell-data-dirs-from-nix-profiles branch from 86c5bfc to ba4cefe Compare October 22, 2017 19:02
@roastiek
Copy link
Contributor Author

@michalrus it's rebased

@michalrus
Copy link
Member

Cool, thank you! (ノ^_^)ノ

@FRidh, WDYT?

@FRidh FRidh merged commit 891c372 into NixOS:master Oct 23, 2017
@michalrus
Copy link
Member

Awesome, thank you, all! 🤗

svend added a commit to svend/dotfiles that referenced this pull request Oct 30, 2017
aspell does not find the dictionary installed in config.nix after the following
change:

NixOS/nixpkgs#30234
@roastiek roastiek deleted the aspell-data-dirs-from-nix-profiles branch November 6, 2017 16:44
jian-lin added a commit to linj-fork/nixpkgs that referenced this pull request Aug 16, 2023
We set[1] ASPELL_CONF to the last nix profile containing lib/aspell in
2013.  In 2017, aspell is patched[2] to search NIX_PROFILES, which
makes [1] not needed any more.

Deleting it is also agreed in this discussion[3].

[1]: 0192c02
[2]: ba4cefe
[3]: NixOS#30234
jian-lin added a commit to linj-fork/nixpkgs that referenced this pull request Aug 16, 2023
We set[1] ASPELL_CONF to the last nix profile containing lib/aspell in
2013.  In 2017, aspell is patched[2] to search NIX_PROFILES, which
makes [1] not needed any more.

Deleting it is also agreed in this discussion[3].

[1]: 0192c02
[2]: ba4cefe
[3]: NixOS#30234
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants