4 ms·
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 <nix
by scoopertrooper 4y ago
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";
}
- delroth 4y agoAs usual for ChatGPT this is full of mistakes and bad code. The buildPhase and installPhase it writes are completely unnecessary and worse than the default, the configurePhase might work in some cases but most likely won't, and it's unnecessary when instead autoreconfHook should be used, stdenv/autoconf should be taken as an argument for the function returning the derivation, autoconf should be a nativeBuildInput, make is already in stdenv, etc.
- steeleduncan 4y ago> sha256 = "0xabcd1234"; Am I right in assuming this is a ChatGPT misunderstanding, or is it a wildcard SHA256 in nix to allow any download?
- tadfisher 4y agoDefinitely not a wildcard, such things are not allowed. You can fetch at evaluation time with the built-in fetchers (builtins.fetchgit, builtins.fetchTarball, etc) and not provide a hash, which makes the expression "impure", which means the expression wouldn't be acceptable in nixpkgs and it has consequences for flakes.