edit Find elisp modules in standard profiles

 (setq load-path (append (list "~/.nix-profile/share/emacs/site-lisp" "/var/run/current-system/sw/share/emacs/site-lisp") load-path))

edit Tramp

Tramp needs to call `ls` and `id` but it will not find them on a NixOS machine without additional configuration because they are not in the usual places. To fix this you can add the following to your ~/.emacs

(require 'tramp) 
(add-to-list 'tramp-remote-path "/var/run/current-system/sw/bin")

You can then edit local files as root e.g.

C-x C-f /su::/etc/nixos/configuration.nix

To login to a remote NixOS machine which uses port 1234 for ssh:

C-x C-f /ssh:username@hostname#1234:/

edit Enable Nix mode

 (setq auto-mode-alist (append '(("\\.nix$" . nix-mode)) auto-mode-alist))
 (autoload 'nix-mode "nix-mode" "nix mode" t)