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

Single file usage of nix-buffer #8

Open
matthewbauer opened this issue Jan 31, 2018 · 4 comments
Open

Single file usage of nix-buffer #8

matthewbauer opened this issue Jan 31, 2018 · 4 comments
Assignees

Comments

@matthewbauer
Copy link
Contributor

Right now, I don't think there is a way to get nix-buffer to work without a separate dir-locals.nix. It seems like there should be a way to set it up entirely through the `file local variables'.

For instance, I have a Haskell file that doesn't have any Stack/Cabal/etc. dependencies associate with it. Is there a way I can include dependencies in it?

I basically want to setup something like this:

-- Local Variables:
-- nix-buffer-script: "with import <nixpkgs> {}; nixBufferBuilders.withPackages [
--   haskellPackages.ghcWithPackages (pkgs: with pkgs; [ random QuickCheck parsec ])
-- ]"
-- eval: (and (require 'nix-buffer nil t) (nix-buffer))
-- End:

and have it work out of the box. Is that seem reasonable? This is just me brainstorming how to do this right now.

@shlevy
Copy link
Owner

shlevy commented Feb 1, 2018

You could possibly use nix-buffer--nix-build for this already, but I wouldn't object to a better interface

@matthewbauer
Copy link
Contributor Author

Do you think it's okay to bypass the safety checks? In this case there's not really a "file" in the same way as for dir-locals.nix. I guess I can make it just use the file name alternatively.

@shlevy
Copy link
Owner

shlevy commented Feb 1, 2018

Yeah, you can bypass the security checks, you're already running a file-local eval

matthewbauer added a commit to matthewbauer/nix-buffer that referenced this issue Feb 15, 2018
add-nix-buffer-with-string can be used to call nix-buffer with a
string so you don’t need to have a dir-locals.nix

This is how I set it up in a Haskell program: (put at the end of the file)

-- Local Variables:
-- eval: (nix-buffer-with-string "let pkgs = import <nixpkgs> {};
--   in pkgs.nixBufferBuilders.withPackages
--   [(pkgs.haskellPackages.ghcWithPackages (self: with self; [parsec QuickCheck hpc]))]")
-- End:

Fixes shlevy#8
@shlevy
Copy link
Owner

shlevy commented Sep 23, 2022

@matthewbauer Let me know if you plan to pick this up again, or we can close it out for now.

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

No branches or pull requests

2 participants