nixpkgs/pkgs/os-specific/bsd/netbsd/default.nix
John Ericson 5f134ec6cf Clean up cross bootstrapping
For a long time, we've had `crossLibcStdenv`, `*Cross` libc attributes,
and `*bsdCross` pre-libc package sets. This was always bad because
having "cross" things is "not declarative": the naming doesn't reflect
what packages *need* but rather how we *provide* something. This is
ugly, and creates needless friction between cross and native building.

Now, almost all of these `*Cross` attributes are gone: just these are
kept:

- Glibc's and Musl's are kept, because those packages are widely used
  and I didn't want to risk changing the native builds of those at this
  time.

- generic `libcCross`, `theadsCross`, and friends, because these relate
  to the convolulted GCC bootstrap which still needs to be redone.

The BSD and obscure Linux or freestnanding libcs have conversely all
been made to use a new `stdenvNoLibc`, which is like the old
`crossLibcStdenv` except:

1. It usable for native and cross alike

2. It named according to what it *is* ("a standard environment without
   libc but with a C compiler"), rather than some non-compositional
   jargon ("the stdenv used for building libc when cross compiling",
   yuck).

I should have done this change long ago, but I was stymied because of
"infinite recursions". The problem was that in too many cases we are
overriding `stdenv` to *remove* things we don't need, and this risks
cyles since those more minimal stdenvs are used to build things in the
more maximal stdenvs.

The solution is to pass `stage.nix` `stdenvNoCC`, so we can override to
*build up* rather than *tear down*. For now, the full `stdenv` is also
passed, so I don't need to change the native bootstraps, but I can see
this changing as we make things more uniform and clean those up.

(adapted from commit 51f1ecaa59)
(adapted from commit 1743662e55)
2024-09-06 10:26:56 -04:00

183 lines
4.5 KiB
Nix

{
lib,
stdenvNoLibc,
stdenvNoCC,
makeScopeWithSplicing',
generateSplicesForMkScope,
buildPackages,
fetchcvs,
}:
let
otherSplices = generateSplicesForMkScope "netbsd";
buildNetbsd = otherSplices.selfBuildHost;
in
makeScopeWithSplicing' {
inherit otherSplices;
f = (
self:
lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
}
// {
version = "9.2";
defaultMakeFlags = [
"MKSOFTFLOAT=${
if
stdenvNoCC.hostPlatform.gcc.float or (stdenvNoCC.hostPlatform.parsed.abi.float or "hard") == "soft"
then
"yes"
else
"no"
}"
];
compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isNetBSD) self.compat;
stdenvLibcMinimal = stdenvNoLibc.override (old: {
cc = old.cc.override {
libc = self.libcMinimal;
noLibc = false;
bintools = old.cc.bintools.override {
libc = self.libcMinimal;
noLibc = false;
sharedLibraryLoader = null;
};
};
});
# The manual callPackages below should in principle be unnecessary because
# they're just selecting arguments that would be selected anyway. However,
# if we don't perform these manual calls, we get infinite recursion issues
# because of the splices.
compat = self.callPackage ./pkgs/compat/package.nix {
inherit (buildPackages) coreutils;
inherit (buildNetbsd) makeMinimal;
inherit (self) install;
};
config = self.callPackage ./pkgs/config.nix {
inherit (buildNetbsd) makeMinimal install;
inherit (self) cksum;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (self) headers sys-headers ld_elf_so;
inherit (buildNetbsd)
netbsdSetupHook
makeMinimal
install
genassym
gencat
lorder
tsort
statHook
;
};
include = self.callPackage ./pkgs/include.nix {
inherit (buildNetbsd)
makeMinimal
install
nbperf
rpcgen
;
inherit (buildPackages) stdenv;
};
install = self.callPackage ./pkgs/install/package.nix {
inherit (self)
fts
mtree
make
compatIfNeeded
;
inherit (buildNetbsd) makeMinimal;
};
libcMinimal = self.callPackage ./pkgs/libcMinimal/package.nix {
inherit (self) headers csu;
inherit (buildNetbsd)
netbsdSetupHook
makeMinimal
install
genassym
gencat
lorder
tsort
statHook
rpcgen
;
};
libpthread-headers = self.callPackage ./pkgs/libpthread/headers.nix { };
librpcsvc = self.callPackage ./pkgs/librpcsvc.nix {
inherit (buildNetbsd)
netbsdSetupHook
makeMinimal
install
lorder
tsort
statHook
rpcgen
;
};
libutil = self.callPackage ./pkgs/libutil.nix {
inherit (buildNetbsd)
netbsdSetupHook
makeMinimal
install
lorder
tsort
statHook
;
};
lorder = self.callPackage ./pkgs/lorder.nix { inherit (buildNetbsd) makeMinimal install; };
mtree = self.callPackage ./pkgs/mtree.nix { inherit (self) mknod; };
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit (buildNetbsd)
netbsdSetupHook
makeMinimal
install
tsort
lorder
;
inherit (buildPackages) mandoc;
inherit (buildPackages.buildPackages) rsync;
};
makeMinimal = self.callPackage ./pkgs/makeMinimal.nix { inherit (self) make; };
# See note in pkgs/stat/package.nix
stat = self.callPackage ./pkgs/stat/package.nix { inherit (buildNetbsd) makeMinimal install; };
# See note in pkgs/stat/hook.nix
statHook = self.callPackage ./pkgs/stat/hook.nix { inherit (self) stat; };
sys-headers = self.callPackage ./pkgs/sys/headers.nix {
inherit (buildNetbsd)
makeMinimal
install
tsort
lorder
statHook
uudecode
config
genassym
;
};
tsort = self.callPackage ./pkgs/tsort.nix { inherit (buildNetbsd) makeMinimal install; };
}
);
}