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

Static nix-shell shebangs #447

Closed
timokau opened this issue Nov 18, 2018 · 6 comments
Closed

Static nix-shell shebangs #447

timokau opened this issue Nov 18, 2018 · 6 comments

Comments

@timokau
Copy link
Contributor

timokau commented Nov 18, 2018

I want to use nix-shell shebangs in my personal script collection to make sure all the needed dependencies are available. That has two disadvantages however:

  • it adds significant overhead (~half a second on my machine if all dependencies are already present)
  • dependencies may be garbage collected so usage of scripts may need internet access

So what I'd actually like is nix-shell like dependency declaration that is resolved statically whenever I update my channels. I've hacked together a proof of concept to do this in home-manager: I iterate through all my scripts, parse the nix-shell shebang line and generate a wrapper script that sets PATH. It is very hacky at the moment and I'm not sure yet if I will improve it in the future, but I thought it couldn't hurt to share it here. What do you think about including something similar as a home-manager library function?

Here is my POC which I import in my home.nix.

@wiedzmin
Copy link

This is my solution for python: https://github.com/wiedzmin/nixos-config/blob/master/modules/util.nix#L9. Will look into your PoC, looks interesting.

@stale
Copy link

stale bot commented Apr 29, 2021

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label Apr 29, 2021
@timokau
Copy link
Contributor Author

timokau commented Apr 29, 2021

This is just a proof of concept and not very actionable at this point. It would need quite a bit of polishing before it could be included in home-manager. I'll close this for now. Please leave a message if you are interested in this issue and think that it should be re-opened.

@timokau timokau closed this as completed Apr 29, 2021
@timokau
Copy link
Contributor Author

timokau commented Apr 29, 2021

I noticed that there are a few reactions to this issue. That may be a reason to leave it open. I do not plan to work on this though, at least not in the near future. The stale bot was probably added to cut down on the backlog, so I'll leave this closed unless somebody wants to push it forward. I'd be happy if somebody else comes up with a solution that can be integrated into home-manager.

@rycee
Copy link
Member

rycee commented Apr 30, 2021

Yeah, I think it is a good idea. But I would suggest creating a separate tool that provides this feature, then we can use it here. It would then also be useful for people not using Home Manager.

@timokau
Copy link
Contributor Author

timokau commented May 8, 2021

I agree, it would be very nice to have this as an external tool. It's currently hard to integrate such a tool into the home-manager and nixos profile generation though. The scripts should be wrapped/patched at "home-manager build" time and then be placed in the profile. The way forward would probably be a library that you could import into your nixos and home-manager configuration. As I said, I don't have any plans to work in this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants