Commit d9c9da5d authored by John Ericson's avatar John Ericson
Browse files

netbsd.makeMinimal: Make it possible to override the rules

parent 4615c9da
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
{
  lib,
  mkDerivation,
  fetchNetBSD,
  stdenv,
  bsdSetupHook,
  netbsdSetupHook,
  rsync,
}:

mkDerivation {
  path = "share/mk";
  sha256 = "0w9x77cfnm6zwy40slradzi0ip9gz80x6lk7pvnlxzsr2m5ra5sy";
  version = "9.2";
  noCC = true;

  buildInputs = [ ];
  nativeBuildInputs = [
    bsdSetupHook
    netbsdSetupHook
    rsync
  ];

  dontBuild = true;

  postPatch =
    ''
      substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
        --replace '-o ''${DOCOWN}' "" \
        --replace '-g ''${DOCGRP}' ""
      for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
        substituteInPlace $mk \
          --replace '-o ''${BINOWN}' "" \
          --replace '-g ''${BINGRP}' ""
      done
      substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
        --replace '-o ''${KMODULEOWN}' "" \
        --replace '-g ''${KMODULEGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
        --replace '-o ''${LIBOWN}' "" \
        --replace '-g ''${LIBGRP}' "" \
        --replace '-o ''${DEBUGOWN}' "" \
        --replace '-g ''${DEBUGGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
        --replace '-o ''${LIBOWN}' "" \
        --replace '-g ''${LIBGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
        --replace '-o ''${MANOWN}' "" \
        --replace '-g ''${MANGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
        --replace '-o ''${NLSOWN}' "" \
        --replace '-g ''${NLSGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
        --replace '-o ''${BINOWN}' "" \
        --replace '-g ''${BINGRP}' "" \
        --replace '-o ''${RUMPBINOWN}' "" \
        --replace '-g ''${RUMPBINGRP}' "" \
        --replace '-o ''${DEBUGOWN}' "" \
        --replace '-g ''${DEBUGGRP}' ""

       substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
         --replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
       substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
         --replace /bin/rm rm
    ''
    + lib.optionalString stdenv.targetPlatform.isDarwin ''
      substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
        --replace '-Wl,--fatal-warnings' "" \
        --replace '-Wl,--warn-shared-textrel' ""
    '';

  installPhase = ''
    cp -r . $out
  '';
}
+6 −46
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
  mkDerivation,
  fetchNetBSD,
  stdenv,
  make-rules,
}:

mkDerivation {
@@ -11,53 +12,12 @@ mkDerivation {
  version = "9.2";

  postPatch =
    ''
      substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
        --replace '-o ''${DOCOWN}' "" \
        --replace '-g ''${DOCGRP}' ""
      for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
        substituteInPlace $mk \
          --replace '-o ''${BINOWN}' "" \
          --replace '-g ''${BINGRP}' ""
      done
      substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
        --replace '-o ''${KMODULEOWN}' "" \
        --replace '-g ''${KMODULEGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
        --replace '-o ''${LIBOWN}' "" \
        --replace '-g ''${LIBGRP}' "" \
        --replace '-o ''${DEBUGOWN}' "" \
        --replace '-g ''${DEBUGGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
        --replace '-o ''${LIBOWN}' "" \
        --replace '-g ''${LIBGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
        --replace '-o ''${MANOWN}' "" \
        --replace '-g ''${MANGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
        --replace '-o ''${NLSOWN}' "" \
        --replace '-g ''${NLSGRP}' ""
      substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
        --replace '-o ''${BINOWN}' "" \
        --replace '-g ''${BINGRP}' "" \
        --replace '-o ''${RUMPBINOWN}' "" \
        --replace '-g ''${RUMPBINGRP}' "" \
        --replace '-o ''${DEBUGOWN}' "" \
        --replace '-g ''${DEBUGGRP}' ""

    make-rules.postPatch
    + ''
      # make needs this to pick up our sys make files
       export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""

       substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
         --replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
       substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
         --replace /bin/rm rm
    ''
    + lib.optionalString stdenv.isDarwin ''
      substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
        --replace '-Wl,--fatal-warnings' "" \
        --replace '-Wl,--warn-shared-textrel' ""
      appendToVar NIX_CFLAGS_COMPILE "-D_PATH_DEFSYSPATH=\"$out/share/mk\""
    '';

  postInstall = ''
    make -C $BSDSRCDIR/share/mk FILESDIR=$out/share/mk install
  '';
+6 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
  netbsdSetupHook,
  rsync,
  make,
  make-rules,
}:

mkDerivation {
@@ -22,7 +23,9 @@ mkDerivation {

  postPatch = ''
    patchShebangs $COMPONENT_PATH/configure
    ${make.postPatch}

    # make needs this to pick up our sys make files
    appendToVar NIX_CFLAGS_COMPILE "-D_PATH_DEFSYSPATH=\"$out/share/mk\""
  '';

  buildPhase = ''
@@ -39,10 +42,10 @@ mkDerivation {
    install -D nbmake $out/bin/nbmake
    ln -s $out/bin/nbmake $out/bin/make
    mkdir -p $out/share
    cp -r $BSDSRCDIR/share/mk $out/share/mk
    cp -r ${make-rules} $out/share/mk

    runHook postInstall
  '';

  extraPaths = [ make.src ] ++ make.extraPaths;
  extraPaths = [ make.src ];
}