syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.65k stars 4.89k forks source link

[nixos] `run-hooks: Symbol’s function definition is void: nixfmt-on-save-mode` #15956

Closed sir4ur0n closed 1 year ago

sir4ur0n commented 1 year ago

Description :octocat:

When opening a Nix file, I get this error:

run-hooks: Symbol’s function definition is void: nixfmt-on-save-mode

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart:

run-hooks: Symbol’s function definition is void: nixfmt-on-save-mode

Expected behaviour: :heart: :smile: No error.

System Info :computer:

Backtrace :paw_prints:

N/A.

15cm commented 1 year ago

I fix it locally by adding the hook by myself for now https://github.com/15cm/spacemacs-config/commit/6d494d6f529a1804d848539264e088c2d8daa8be

(add-hook 'before-save-hook 'nix-format-before-save)
lebensterben commented 1 year ago

this could be fixed by adding

:commands nixfmt-on-save-mode

to the use-package call

sir4ur0n commented 1 year ago

I think the root cause is https://github.com/NixOS/nix-mode/commit/c18a24e9ac569a221e88ba9d74d52c7b02b6eb77

If I'm not mistaken, nixfmt-on-save-mode was reverted (reformatter-define nixfmt) and instead one now must use nix-format-before-save (the same command @15cm uses in his hack).

So the actual fix for Spacemacs is to revert https://github.com/syl20bnr/spacemacs/commit/821bd9cc683575af0996c8e2b3e42452bb9c684a

I will open a PR to fix this.