Trying to package Doom-emacs

I am trying to package doom-emacs and I came up with this small derivation (?) to match with the instructions from the repository :

{pkgs ? import <nixpkgs> {}, ...}:

let
	doomSrc = pkgs.fetchFromGitHub {
		owner = "hlissner";
		repo = "doom-emacs";
		rev = "v2.0.9";
		sha256 = "190ygybn0dn0z98dfv4d5yh4np6ph7wlaz04agw9r49rzwf8g23y";
	};
in
	(pkgs.emacs).overrideAttrs (attrs: {
		postInstall = (attrs.postInstall or "") + ''
		mv ${doomSrc} $HOME/.emacs.d
		rm -rf $HOME/.emacs.d/{LICENSE,README,.gitignore,.travis.yml,.github}
		$HOME/.emacs.d/bin/doom quickstart
		'';
	})

But of course, as $HOME is set to /homeless-shelter (as stated in the manual), a call to nix-build doom-emacs.nix sends back :

mv: cannot move '/nix/store/j36c7sg381fw03x58ylhyikgxi3c0b5q-source' to '/homeless-shelter/.emacs.d': No such file or directory

So how would you package this to achieve the same result ?

Sometimes a build system depends on $HOME to exist to store temporary files, in that case it’s quite common for the build to override that variable to another temporary location. Just grep through nixpkgs and you’ll find a ton of examples.

That being said, it looks like you are trying to install doomSrc into the $HOME. Build results are only kept if they are installed somewhere into the $out path. Have a look at the other plugins, I guess emacs has a way to maintain it’s extensions in another folder.