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

Add 'environment.opt' (similar to 'environment.etc') #99574

Closed
wants to merge 1 commit into from

Conversation

@gytis-ivaskevicius
Copy link

@gytis-ivaskevicius gytis-ivaskevicius commented Oct 4, 2020

Motivation for this change

I'd like to have an environment.etc alternative for /opt folder. Use case: a way to pin some specific folders that are generated by Nix (in my particular use case this is used to integrate with Intellij Idea and multiple JDK's):

  environment.opt = {
    # Main use case would be pinning stuff like NodeJS or Java home folders to make users life easier 
    "jdk8".source = pkgs.jdk8.home;
    "jdk11".source = pkgs.jdk11.home;
  };

The configuration is mostly copy-pasted from etc.nix.
One issue is that /opt folder is created without read permissions (why!?!??!), as a workaround I added chmod within the script. This should probably be handled as whenever /opt folder is generated (but then we run into other issues like migrating from older generations. TL;DR: I don't know what is an appropriate way to handle it)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • 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 nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@symphorien
Copy link
Contributor

@symphorien symphorien commented Oct 4, 2020

You can achieve the same with systemd.tmpfiles.rules (L+).

@gytis-ivaskevicius
Copy link
Author

@gytis-ivaskevicius gytis-ivaskevicius commented Oct 4, 2020

@symphorien I am not sure what you mean, may I see an example?

@aanderse
Copy link
Contributor

@aanderse aanderse commented Oct 4, 2020

See https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html

Very roughly something like this:

systemd.tmpfiles.rules = [
  "L+ /opt/jdk-or-whatever - - - - - - ${pkgs.jre}"
];
@gytis-ivaskevicius
Copy link
Author

@gytis-ivaskevicius gytis-ivaskevicius commented Oct 4, 2020

Oh great, that sounds exactly what I need. Should this PR be closed? All it would add is a nicer way of implementing it

@aanderse
Copy link
Contributor

@aanderse aanderse commented Oct 4, 2020

Yes. /etc is very much so managed by NixOS and this flows with the nix philosophy. Managing /opt wouldn't really make sense under this philosophy. Since tmpfiles.d solves your use case nicely we can close this PR.

Thanks!

@aanderse aanderse closed this Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.