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

aspellWithDicts: create derivation with aspell and selected dictionaries #26622

Closed
wants to merge 1 commit into from

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Jun 16, 2017

Currently, aspell checks the active profiles for dictionaries. While
this may be convenient, it does not work with nix-shell and it doesn't
allow any isolation.

This commit adds the possibility to use composition by creating a
derivation with buildEnv that contains aspell and selected
dictionaries.

Nix example:

my_aspell = aspellWithDicts(ps: with ps; [ en nl ])

nix-shell example:

nix-shell -p 'aspellWithDicts(ps: with ps; [ en nl ])'

@FRidh
Copy link
Member Author

FRidh commented Jun 16, 2017

Composition always increases space usage. The example derivation is 4 MB. We may choose to create only symbolic links for the dictionaries and then wrappers for the executables.

@FRidh FRidh mentioned this pull request Jun 16, 2017
postBuild = ''
# wrapProgram $out/bin/aspell --set ASPELL_CONF "data-dir $out/lib/aspell"
# We cannot simply use wrapProgram because we're not allowed to modify items in $out/bin
unlink $out/bin
Copy link
Member

Choose a reason for hiding this comment

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

Why unlink rather than the more conventional rm?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, of course, removing individual items with rm doesn't work because the directory containing them is a symbolic link itself. I actually hadn't tried using rm on symbolic link to /bin.

@lheckemann
Copy link
Member

Did you consider making the dictionaries directory a separate derivation? That would avoid modifying the result of buildEnv and the need to remove part of what it created. It would also result in the manifest.nix remaining accurate.

@FRidh
Copy link
Member Author

FRidh commented Jun 16, 2017

Did you consider making the dictionaries directory a separate derivation?

Yes, if I understand you correctly. My idea was to have then two derivations, one with wrappers pointing to the other consisting of symlinks to the dicts.

We may choose to create only symbolic links for the dictionaries and then wrappers for the executables.

@bjornfor
Copy link
Contributor

I prefer having the option of installing things in my profile. I don't think you need to remove that feature to get what you want. When ASPELL_CONF is set in the pure wrapper, the impure wrapper automatically disables profile traversal. (You can also unset NIX_PROFILES in the pure wrapper just to be sure.)

@FRidh
Copy link
Member Author

FRidh commented Jun 16, 2017

@bjornfor good point, I had missed that. I'll update the PR.

Currently, `aspell` checks the active profiles for dictionaries. While
this may be convenient, it does not work with `nix-shell` and it doesn't
allow any isolation.

This commit adds the possibility to use composition by creating a
derivation with `buildEnv` that contains `aspell` and selected
dictionaries.

Nix example:

my_aspell = aspellWithDicts(ps: with ps; [ en nl ])

`nix-shell` example:

nix-shell -p 'aspellWithDicts(ps: with ps; [ en nl ])'
@FRidh
Copy link
Member Author

FRidh commented Jun 16, 2017

It may be good if the different spell checkers work similarly.
For hunspell there is also a hunspellWithDicts which only wraps hunspell https://github.com/NixOS/nixpkgs/blob/release-17.03/pkgs/development/libraries/hunspell/wrapper.nix

@alexeymuranov
Copy link
Contributor

alexeymuranov commented Jun 16, 2017

Just a remark about hunspell. I didn't manage to make hunspell work even using hunspellWithDicts. Only US English works, and it does so without any special configuration. For some reason, Hebrew shows up in menus without having been (explicitly) installed.

Edit. Maybe i am a bit confused: probably it is not hunspell that does not work, but its dictionaries are not seen by different applications, like Evolution or gEdit.

@FRidh
Copy link
Member Author

FRidh commented Jun 19, 2017

Edit. Maybe i am a bit confused: probably it is not hunspell that does not work, but its dictionaries are not seen by different applications, like Evolution or gEdit.

Applications typically need to be compiled with support and they may assume/hardcode a path where the dictionaries could be. See #26654.

@FRidh
Copy link
Member Author

FRidh commented Jul 2, 2017

@lheckemann alternative at FRidh@3d72a3c. Note the commit message needs to be updated.

@bennofs
Copy link
Contributor

bennofs commented Jul 16, 2017

@FRidh can you update the PR to the alternate version? I'd really like to see this in nixpkgs 👍

@FRidh FRidh self-assigned this Jul 16, 2017
@FRidh
Copy link
Member Author

FRidh commented Jul 17, 2017

Pushed c0cf196 to master.

@FRidh FRidh closed this Jul 17, 2017
@FRidh FRidh deleted the aspell branch August 2, 2017 17:27
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

5 participants