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

Make safety checks optional and add nix-buffer-with-string #12

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

matthewbauer
Copy link
Contributor

@matthewbauer matthewbauer commented Feb 15, 2018

By default safety checks are still performed. However, they are not performed when using nix-buffer-string because it is intended to be evaluated directly.


A question on the safety of nix-build though:

Is there a security concern with running arbitrary nix-build give that we have enabled:

  • multi-user mode
  • sandboxing
    ?

It seems to me that nix-build should be safe to run by design (I guess it could eat up resources though).

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
Each file will have a unique Nix expression so use that as our
‘state-dir’ name
@matthewbauer matthewbauer changed the title Make safety checks optional and add nix-buffer-string Make safety checks optional and add nix-buffer-wit˙-string Feb 15, 2018
@matthewbauer matthewbauer changed the title Make safety checks optional and add nix-buffer-wit˙-string Make safety checks optional and add nix-buffer-with-string Feb 15, 2018
@shlevy
Copy link
Owner

shlevy commented Feb 16, 2018

There's no security issue running nix-build, just on evaluating the results.

@shlevy
Copy link
Owner

shlevy commented Feb 16, 2018

(though probably eventually we should run it in restricted mode...)

nix-buffer.el Outdated
@@ -152,42 +157,56 @@ EVENT The process status change event string."
(kill-buffer out-buf)
(kill-buffer err-buf))))))

(defun nix-buffer--nix-build (root expr-file)
(defun nix-buffer--nix-build (expr-file &optional root skip-safety)
Copy link
Owner

Choose a reason for hiding this comment

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

Erm, why is root optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it will break anything that needs 'root' like haskellMonoRepo. My thinking was in the context of 'nix-buffer-with-string' you wouldn't want to have a 'root' path set. For instance, you could use it in a script that didn't have any directory or buffer associated.

nix-buffer.el Outdated
(defun nix-buffer-with-string (expression)
"Start ‘nix-buffer’ but with a string EXPRESSION."
(interactive)
(let ((expr-file (make-temp-file "nix-buffer")))
Copy link
Owner

Choose a reason for hiding this comment

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

Hm, can't we just use nix-build -E instead of making a temp file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually that's probably a good idea. I had thought it would save on code duplication but it won't make a big difference.

@@ -154,9 +159,9 @@ EVENT The process status change event string."

(defun nix-buffer--nix-build (root expr-file)
"Start the nix build.
ROOT The path we started from.
EXPR-FILE The file containing the nix expression to build.
Copy link
Owner

Choose a reason for hiding this comment

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

Should these be switched back?

@shlevy
Copy link
Owner

shlevy commented Feb 17, 2018

Did you mean to drop the safety skipping?

@shlevy shlevy marked this pull request as draft September 23, 2022 16:53
@shlevy shlevy assigned shlevy and matthewbauer and unassigned shlevy Sep 23, 2022
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.

2 participants