-
-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't conflate dependencies in setup.sh
#4855
Comments
I agree that "native" is confusing, so +1 for changing that. But can you explain what is wrong with the GNU terminology? Is there something better? At least the meaning of GNU build/host/target is well documented (and widely used because of autotools), although arguably not intuitive. (But I guess nothing is.) |
GNU terminology:
Current nix terminology in setup.sh env vars:
nixpkgs expressions have "buildInputs", because that's the common when not So we have these nix var → env var correspondences:
Another option, like what you want, would be to have these correspondences:
This option, though, makes a weird crossing of names in case of cross building. Regards, On Thu, Nov 06, 2014 at 02:52:17AM -0800, Eelco Dolstra wrote:
|
We could drop the 'build' of 'buildInputs', then use GNU prefixes when cross-building:
I'm not certain I understand the comment in nixpkgs/pkgs/stdenv/adapters.nix Line 102 in 5ad448d
|
Why not just use |
@Mathnerd314 refactoring too many files? |
I think this sedscript should be sufficient:
It catches the other variations, e.g. extraNativeBuildInputs. |
@viric: Ah, I didn't think of that "GNU target" doesn't involve dependencies. So, when talking about build inputs, we have only two platforms to care about, not three. Good. @iElectric: I think "cross" is an unfortunate name, because unless you're doing actual cross-compilation, "cross" inputs would be build inputs for the build host, not for the target. @edolstra: I like both your proposals. But seing as derivations have a When we rename build inputs, I think it'd be good idea to also rename the |
On the other hand, when doing cross-compilation, the two systems are often called "host" and "target". E.g. Buildroot uses this naming scheme. |
To be honest, I think that renaming is going to cause too much work/breakage at this point. For the overrideDerivation issue, it would be enough to move the concatenating of |
Oh, don't say that! :-) What kind of breakage? Internal to nixpkgs or for users with out-of-tree expressions? I'm very much in favor of a rename, some time in the future. |
Any progress? |
Alternative approach. Because packages like flex, pkgconfig, ecc. are usually (or always) used as nativeBuildInputs, what about setting for them a We get rid of native vs cross build inputs, and instead each package declare itself as native vs cross build input, or in general its role in the build process. Otherwise it's a maintainance burden to understand which package goes native vs cross, or also renaming this kind of variables. We'll only have one buildInputs. In general tools are native, libraries are cross. The multi output branch should even help with this distinction, of course with the possibility to override the role. It's not much useful to keep using native vs cross, if one (like me) is not going or forget to use it. So just let's make this automatic. |
@lethalman 👍 I think this makes sense, but you probably want to consider the lack of the file as a proof of a native packages versus a cross-compiled package, Thus having Thus the rule would be that if the file does not exists, we assume that this is the same system, and if it does, then we check against the system on which we are building. |
I don't see how this could be solved via |
A data point, how the Buildroot embedded build system solve this: Buildroot has two types of dependencies, one for normal dependencies (for the target architecture) and one for the (build) host. Both go into the same dependency list:
The package "expression" for libaaa (a Makefile snippet) decides what type of packages are created:
I like the explicitness of this approach. I'd like to see this in nixpkgs:
|
But some packages can be used both as target and host inputs. So I think there is value in having explicit distinction between host/target derivations (i.e. libfoo vs libfoo.hostDrv). |
@bjornfor that's the exception, and we already have that... it's called |
To be clear, |
+1 regarding fixing the overrideDerivation behaviour. Just finished running into this adding libibverb as a dependency to openmpi to get infiniband support. openmpi.overrideDerivation (oldattrs: {
buildInputs = oldattrs.buildInputs ++ [ libibverbs ];
} ) gave a derivation with buildInputs set to the extra libibverbs
while directly modifying
|
AFAICT solving #10721 will solve the |
No consensus how to move forward here, bumping milestone. |
Any news? |
This won't make it to 16.09 |
#18660 adds a new |
…Inputs When not cross compiling, nativeBuildInputs and buildInputs have identical behaviour. Currently that is implemented by having mkDerivation do a concatenation of those variables in Nix code and pass that to the builder via the nativeBuildInputs attribute. However, that has some annoying side effects, like `foo.buildInputs` evaluating to `[ ]` even if buildInputs were specified in the nix expression for foo. Instead, pass buildInputs and nativeBuildInputs in separate variables as usual, and move the logic of cross compilation vs. native compilation to the stdenv builder script. This is probably a tiny bit uglier but fixes the previous problem. Issue NixOS#4855.
In #26805 I do add 4 more sorts of dependencies giving us:
Packages do not care what the build platform of the dep is, because they merely need it to exist. In practice however, the build platform of the dep is the build platform of the consumer. |
The build-host-target triad is quite clear, but
E. g. we can build GCC on linux (build), which will run on Windows (host), but compile binaries for solaris (target). |
@ip1981 That's all true. Precisely because "target" is not applicable to most software, yet that's not clear from the name alone, I prefixed with underscores the "bad" dependencies to discourage accidental use. |
N.B. Editted my table now that #26805 now introduces even more dependencies. |
@dezgeg Sure, that makes sense to me. |
setup.hs
setup.hs
setup.sh
setup.sh
setup.sh
Remaining bike-shed is in #28327 |
setup.sh
setup.sh
We currently have the confusing situation that the
buildInputs
attribute gets passed to the builder via thenativeBuildInputs
environment variable:(Pan declares a
buildInputs
attribute.)Also, "native" is somewhat ambiguous: native to the build machine, or native to the target machine? However the GNU terminology (
build
andhost
) is not really better.Maybe it would be better to always use
buildInputs
for the native (build machine) dependencies, and something liketargetBuildInputs
for the cross-built dependencies. Or not usebuildInputs
in setup.sh at all and usenativeBuildInputs
andtargetBuildInputs
to prevent confusion.Ping @viric
The text was updated successfully, but these errors were encountered: