Newbie question: how to modify stdenv's Make program in mkShell?

Hello, people!

I am now developing a “new” build system for Higan. But, for the sake of debug, I want to change the default gmake to remake. How can I do it?

# file: shell.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
    nativeBuildInputs = with pkgs; [ meson ninja ];
    buildInputs = [ /* a bunch of packages */ ];
}

I’m not sure, but here’s how I tried to figure it out:

[cody@nixos:~]$ nix repl '<nixpkgs>'
Welcome to Nix version 2.3.3. Type :? for help.

Loading '<nixpkgs>'...
Added 11588 variables.

nix-repl> ashell = pkgs.mkShell {}

nix-repl> ashell.
ashell.__ignoreNulls                ashell.depsBuildBuildPropagated     ashell.doCheck                      ashell.nobuildPhase                 ashell.passthru                     ashell.strictDeps
ashell.all                          ashell.depsBuildTarget              ashell.doInstallCheck               ashell.out                          ashell.patches                      ashell.system
ashell.args                         ashell.depsBuildTargetPropagated    ashell.drvAttrs                     ashell.outPath                      ashell.phases                       ashell.type
ashell.buildInputs                  ashell.depsHostHost                 ashell.drvPath                      ashell.outputName                   ashell.propagatedBuildInputs        ashell.userHook
ashell.builder                      ashell.depsHostHostPropagated       ashell.meta                         ashell.outputUnspecified            ashell.propagatedNativeBuildInputs
ashell.configureFlags               ashell.depsTargetTarget             ashell.name                         ashell.outputs                      ashell.shellHook
ashell.depsBuildBuild               ashell.depsTargetTargetPropagated   ashell.nativeBuildInputs            ashell.overrideAttrs                ashell.stdenv
nix-repl> # NOTE: ashell.stdenv looks promising
nix-repl> ashell.stdenv.
ashell.stdenv.__extraImpureHostDeps     ashell.stdenv.drvPath                   ashell.stdenv.isAarch32                 ashell.stdenv.isx86_32                  ashell.stdenv.preHook
ashell.stdenv.all                       ashell.stdenv.extraBuildInputs          ashell.stdenv.isAarch64                 ashell.stdenv.isx86_64                  ashell.stdenv.setup
ashell.stdenv.allowedRequisites         ashell.stdenv.extraNativeBuildInputs    ashell.stdenv.isBigEndian               ashell.stdenv.lib                       ashell.stdenv.shell
ashell.stdenv.args                      ashell.stdenv.extraSandboxProfile       ashell.stdenv.isCygwin                  ashell.stdenv.meta                      ashell.stdenv.shellPackage
ashell.stdenv.bootstrapTools            ashell.stdenv.fetchurlBoot              ashell.stdenv.isDarwin                  ashell.stdenv.mkDerivation              ashell.stdenv.system
ashell.stdenv.buildPlatform             ashell.stdenv.glibc                     ashell.stdenv.isFreeBSD                 ashell.stdenv.name                      ashell.stdenv.targetPlatform
ashell.stdenv.builder                   ashell.stdenv.hasCC                     ashell.stdenv.isLinux                   ashell.stdenv.out                       ashell.stdenv.type
ashell.stdenv.cc                        ashell.stdenv.hostPlatform              ashell.stdenv.isMips                    ashell.stdenv.outPath
ashell.stdenv.defaultBuildInputs        ashell.stdenv.initialPath               ashell.stdenv.isOpenBSD                 ashell.stdenv.outputName
ashell.stdenv.defaultNativeBuildInputs  ashell.stdenv.is32bit                   ashell.stdenv.isSunOS                   ashell.stdenv.overrides
ashell.stdenv.drvAttrs                  ashell.stdenv.is64bit                   ashell.stdenv.isi686                    ashell.stdenv.platform

Maybe someone can point out how I could have went further to find the answer here and we can learn how to answer this type of question ourselves in the future :slight_smile:

The generic builder has make command
hardcoded
so you would need to override
phases, i.e. set
your own buildPhase, installPhase

You could also create a setup hook (see, for example,
ninja)
to make it easier to use for other people.

If remake is just a compatible fork of gnumake (I wonder why they did
not pass the changes upstream) it might also work to change the package
to install make as a symlink to remake. With nix, such potential
path collisions are fine. Not sure if it would be picked up over the
make from stdenv but it is a good thing to try.

Oh, hardcoded path? Then it is better to call remake inside nativeBuildInputs instead. After all it is just for debugging purposes, and it would be silly to modify stdenv in order to accept a new make-compatible tool just because it is fun.

One thing is support different compilers like Clang or CCache. I don’t think different makes are so important…

See NixOS Search - Loading... .