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

ocamlformat: init at 0.8 #48823

Merged
merged 1 commit into from Oct 23, 2018
Merged

ocamlformat: init at 0.8 #48823

merged 1 commit into from Oct 23, 2018

Conversation

Zimmi48
Copy link
Member

@Zimmi48 Zimmi48 commented Oct 22, 2018

Motivation for this change

Add ocamlformat (supported by Dune 1.4).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

I tested the result with dune build @fmt but not with Emacs because I'm not quite sure how to configure Emacs to use ocamlformat.

@Zimmi48
Copy link
Member Author

Zimmi48 commented Oct 22, 2018

FTR about Emacs, I managed to make it work this way:

  • I added shellHook = "export OCAMLFORMAT_LOCATION=${ocamlformat}"; to my default.nix
  • And the following to my .emacs:
    (setq ocamlformat-location (getenv "OCAMLFORMAT_LOCATION"))
    (when (> (length ocamlformat-location) 0)
     (add-to-list 'load-path (concat ocamlformat-location "/share/emacs/site-lisp"))
     (require 'ocamlformat)
     (add-hook 'tuareg-mode-hook
               (lambda () (add-hook 'before-save-hook 'ocamlformat-before-save))))
    

It's probably not very idomatic Nix, can this be adapted to be useful to everyone?

@Mic92
Copy link
Member

Mic92 commented Oct 22, 2018

I am not an emacs user, but if it become a nix package it could be included like other emacs plugins: https://nixos.org/nixos/manual/index.html#module-services-emacs-adding-packages

Copy link
Contributor

@vbgl vbgl left a comment

Choose a reason for hiding this comment

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

I just tried with emacs and the following:

  (add-to-list 'load-path "~/.nix-profile/share/emacs/site-lisp")
  (require 'ocamlformat)
  (add-hook 'tuareg-mode-hook (lambda () (add-hook 'before-save-hook 'ocamlformat-before-save)))

This works well after globally installing ocamlformat. The situation is similar for other tools (merlin, ocp-indent…).

sha256 = "1i7rsbs00p43362yv7z7dw0qsnv7vjf630qk676qvfg7kg422w6j";
};

nativeBuildInputs = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Why native ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the libraries were not found if there were in buildInputs. I tried to change to nativeBuildInputs at random.

Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot reproduce. Looks suspicious.

Also, the bos library seems not needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I took it from the opam file. But anyways, I can try to reduce the dependencies.

@Zimmi48
Copy link
Member Author

Zimmi48 commented Oct 23, 2018

This works well after globally installing ocamlformat. The situation is similar for other tools (merlin, ocp-indent…).

But this does not work in a nix-shell, right? But I suppose this is something that is acceptable.

@vbgl
Copy link
Contributor

vbgl commented Oct 23, 2018

It will work in a nix shell provided it is also globally installed ;-)

@Zimmi48
Copy link
Member Author

Zimmi48 commented Oct 23, 2018

I don't even have ocamlmerlin globally installed. In the case of ocamlformat it makes even more sense to use it through nix-shell only to have it only in projects that use it. But anyways, the workaround I mentioned works for anyone who wants to use it through nix-shell.

@Zimmi48
Copy link
Member Author

Zimmi48 commented Oct 23, 2018

Updated.

@vbgl
Copy link
Contributor

vbgl commented Oct 23, 2018

@GrahamcOfBorg build ocamlformat

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: ocamlformat

Partial log (click to expand)

moving /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/man to /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/share/man
moving /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/doc to /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/share/doc
shrinking RPATHs of ELF executables and libraries in /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8
shrinking /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/bin/ocamlformat
gzipping man pages under /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/share/man/
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/lib  /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8/bin
patching script interpreter paths in /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8
checking for references to /build in /nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8...
/nix/store/bvjh80wspn8dqsrwyy94fzra2f16qvgb-ocamlformat-0.8

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: ocamlformat

Partial log (click to expand)

installing
Processing file ocamlformat.install as ocamlformat.
post-installation fixup
moving /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/man to /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/share/man
moving /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/doc to /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/share/doc
gzipping man pages under /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/share/man/
strip is /nix/store/g5r4apl0za012ffs6ladinwa5w0m1l3k-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/lib  /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8/bin
patching script interpreter paths in /nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8
/nix/store/apc9v3vxyxa2x8397xjg2l9199nf9f1b-ocamlformat-0.8

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: ocamlformat

Partial log (click to expand)

moving /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/man to /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/share/man
moving /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/doc to /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/share/doc
shrinking RPATHs of ELF executables and libraries in /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8
shrinking /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/bin/ocamlformat
gzipping man pages under /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/share/man/
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/lib  /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8/bin
patching script interpreter paths in /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8
checking for references to /build in /nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8...
/nix/store/fgs4fj0vvjm2iq55xd9krhil2hlxy1rk-ocamlformat-0.8

@vbgl vbgl merged commit cea4806 into NixOS:master Oct 23, 2018
@Zimmi48 Zimmi48 deleted the ocamlformat branch October 23, 2018 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants