Let’s see… home.file
, if you use the home-manager nixos module, will symlink whatever files you ask it to to the specified user’s home directory path. This is pure and declarative, and hence completely permitted in the nixosConfiguration
of flakes even without --impure
.
nix run
won’t start emacs. By default, it will look at your current working directory, and if it or any of its parent directories contain a flake.nix
it will look for an apps.${system}.default
output and if it exists run it. If this happens to point to emacs, it will start emacs.
nix run nixpkgs#emacs
will start emacs, but it will look up emacs in the nixpkgs flake, which is by default downloaded from github when you run that command.
Neither of those nix run
commands at all care whether you use home.file
in any way. They don’t care whether you even have a nixosConfiguration
in your flake outputs, since they don’t interact with it at all.
The emacs that either of those commands may launch will behave normally, so if you used home.file
to install your emacs config, such an emacs instance will load whatever you asked home.file
to create, because it will just be a symlink to an emacs config in e.g. ~/.config/emacs
.
Does that clear it up?
That’s a bit trickier, and depends a bit on what you want to do. But you could create your own packages.${system}.emacs
, and do something like this:
packages.${system}.emacs = pkgs.emacs.override {
siteStart = ./site-start.el;
};
And then create a file similar to the one in nixpkgs in site-start.el
, except configure it to also load your yasnippet and other configuration.
That way you can basically have your own emacs distribution, and run it on any Linux distro just by running nix run github:myuser/myflake#emacs
, and it will come with your yasnippet preinstalled and ready to go, but also execute the user’s local configuration as normal.
Which is kind of a cool idea!
The much more reasonable thing to do is just to move your emacs config into home manager, installing the whole config with home.file
, and assume that there is no existing emacs configuration 
If there is one, home-manager will error out and tell you so, by the way, so you will always have a chance to back it up before you overwrite something.