Why use a tutorial when ChatGPT has you covered?
> How do I create a nix package that clones eMacs from GitHub and builds it from source?
{ pkgs ? import <nixpkgs> {}, fetchFromGitHub }:
let
emacsSrc = fetchFromGitHub {
owner = "emacs-mirror";
repo = "emacs";
rev = "master";
sha256 = "0xabcd1234";
};
in pkgs.stdenv.mkDerivation { name = "emacs";
version = "27.1";
src = emacsSrc;
buildInputs = [ pkgs.autoconf pkgs.make ];
configurePhase = ''
autoconf
./configure --prefix=$out
'';
buildPhase = "make";
installPhase = "make install";
}