deterministic-uname: Overridable platform
Some packages rely on `uname` to configure the host target which breaks cross-compilation. We can have more control over the evaluation of `uname` by placing `deterministic-uname` into the package's `nativeBuildInputs`. However the current `deterministic-uname` is hardcoded to `buildPlatform`. This PR introduces a build argument `forPlatform` to `deterministic-uname` which allows you to override the platform it reports. Example: ```nix deterministic-uname.override { forPlatform = stdenv.hostPlatform; } ```
This commit is contained in:
parent
baa26b9fb9
commit
2ed51a3ff0
@ -5,6 +5,7 @@
|
|||||||
, coreutils
|
, coreutils
|
||||||
, getopt
|
, getopt
|
||||||
, modDirVersion ? ""
|
, modDirVersion ? ""
|
||||||
|
, forPlatform ? stdenv.buildPlatform
|
||||||
}:
|
}:
|
||||||
|
|
||||||
substituteAll {
|
substituteAll {
|
||||||
@ -17,8 +18,8 @@ substituteAll {
|
|||||||
|
|
||||||
inherit coreutils getopt;
|
inherit coreutils getopt;
|
||||||
|
|
||||||
uSystem = if stdenv.buildPlatform.uname.system != null then stdenv.buildPlatform.uname.system else "unknown";
|
uSystem = if forPlatform.uname.system != null then forPlatform.uname.system else "unknown";
|
||||||
inherit (stdenv.buildPlatform.uname) processor;
|
inherit (forPlatform.uname) processor;
|
||||||
|
|
||||||
# uname -o
|
# uname -o
|
||||||
# maybe add to lib/systems/default.nix uname attrset
|
# maybe add to lib/systems/default.nix uname attrset
|
||||||
@ -26,9 +27,9 @@ substituteAll {
|
|||||||
# https://stackoverflow.com/questions/61711186/where-does-host-operating-system-in-uname-c-comes-from
|
# https://stackoverflow.com/questions/61711186/where-does-host-operating-system-in-uname-c-comes-from
|
||||||
# https://github.com/coreutils/gnulib/blob/master/m4/host-os.m4
|
# https://github.com/coreutils/gnulib/blob/master/m4/host-os.m4
|
||||||
operatingSystem =
|
operatingSystem =
|
||||||
if stdenv.buildPlatform.isLinux
|
if forPlatform.isLinux
|
||||||
then "GNU/Linux"
|
then "GNU/Linux"
|
||||||
else if stdenv.buildPlatform.isDarwin
|
else if forPlatform.isDarwin
|
||||||
then "Darwin" # darwin isn't in host-os.m4 so where does this come from?
|
then "Darwin" # darwin isn't in host-os.m4 so where does this come from?
|
||||||
else "unknown";
|
else "unknown";
|
||||||
|
|
||||||
@ -42,11 +43,12 @@ substituteAll {
|
|||||||
mainProgram = "uname";
|
mainProgram = "uname";
|
||||||
longDescription = ''
|
longDescription = ''
|
||||||
This package provides a replacement for `uname` whose output depends only
|
This package provides a replacement for `uname` whose output depends only
|
||||||
on `stdenv.buildPlatform`. It is meant to be used from within derivations.
|
on `stdenv.buildPlatform`, or a configurable `forPlatform`. It is meant
|
||||||
Many packages' build processes run `uname` at compile time and embed its
|
to be used from within derivations. Many packages' build processes run
|
||||||
output into the result of the build. Since `uname` calls into the kernel,
|
`uname` at compile time and embed its output into the result of the build.
|
||||||
and the Nix sandbox currently does not intercept these calls, builds made
|
Since `uname` calls into the kernel, and the Nix sandbox currently does
|
||||||
on different kernels will produce different results.
|
not intercept these calls, builds made on different kernels will produce
|
||||||
|
different results.
|
||||||
'';
|
'';
|
||||||
license = [ licenses.mit ];
|
license = [ licenses.mit ];
|
||||||
maintainers = with maintainers; [ artturin ];
|
maintainers = with maintainers; [ artturin ];
|
||||||
|
Loading…
Reference in New Issue
Block a user