-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
deterministic-uname: init #210102
deterministic-uname: init #210102
Conversation
3994f82
to
8c7a38c
Compare
8c7a38c
to
b06592c
Compare
MACHINE_VAL=@processor@ | ||
PROCESSOR_VAL=unknown | ||
HARDWARE_PLATFORM_VAL=unknown | ||
OPERATING_SYSTEM_VAL=GNU/Linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add uname -o
(-o, --operating-system print the operating system
) to
nixpkgs/lib/systems/default.nix
Lines 88 to 115 in 2377605
# Output from uname | |
uname = { | |
# uname -s | |
system = { | |
linux = "Linux"; | |
windows = "Windows"; | |
darwin = "Darwin"; | |
netbsd = "NetBSD"; | |
freebsd = "FreeBSD"; | |
openbsd = "OpenBSD"; | |
wasi = "Wasi"; | |
redox = "Redox"; | |
genode = "Genode"; | |
}.${final.parsed.kernel.name} or null; | |
# uname -m | |
processor = | |
if final.isPower64 | |
then "ppc64${lib.optionalString final.isLittleEndian "le"}" | |
else if final.isPower | |
then "ppc${lib.optionalString final.isLittleEndian "le"}" | |
else if final.isMips64 | |
then "mips64" # endianness is *not* included on mips64 | |
else final.parsed.cpu.name; | |
# uname -r | |
release = null; | |
}; |
@amjoseph-nixpkgs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO there is no reason for a nixlang expression to need the value of uname -o
at eval-time, is there?
Maybe put the table with those values in this package so people don't use it from random expressions without a good reason. If a good reason appears we can always move it out of fake-uname
into lib/systems
.
Edit: sorry, I had this confused with uname -a
.
Let me look into this.
b06592c
to
6897cba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve of this as it's a lot less controversial that outright replacing uname everywhere. It might be a bit more annoying to apply to the right packages (less scalable), but it's a good first step towards solving impurity issues with uname. If this is applied in too many places we can always reconsider the replacement option.
@@ -26,6 +27,7 @@ stdenv.mkDerivation rec { | |||
perl | |||
gettext | |||
gobject-introspection | |||
fake-uname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it ensured that this uname takes precedence over other uname implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkgs.coreutils |
nixpkgs/pkgs/stdenv/linux/default.nix
Lines 492 to 493 in 6abb95c
initialPath = | |
((import ../generic/common-path.nix) {pkgs = prevStage;}); |
nixpkgs/pkgs/stdenv/generic/default.nix
Lines 133 to 134 in 6abb95c
inherit initialPath shell | |
defaultNativeBuildInputs defaultBuildInputs; |
nixpkgs/pkgs/stdenv/generic/setup.sh
Lines 274 to 287 in 6abb95c
# Set up the initial path. | |
PATH= | |
HOST_PATH= | |
for i in $initialPath; do | |
if [ "$i" = / ]; then i=; fi | |
addToSearchPath PATH "$i/bin" | |
# For backward compatibility, we add initial path to HOST_PATH so | |
# it can be used in auto patch-shebangs. Unfortunately this will | |
# not work with cross compilation. | |
if [ -z "${strictDeps-}" ]; then | |
addToSearchPath HOST_PATH "$i/bin" | |
fi | |
done |
somehow PATH contains the nativeBuildInputs first and then common-path
declare -x PATH="/nix/store/k2vd7w2ixbqbgd9v88am8780111bng7j-pkg-config-wrapper-0.29.2/bin:/nix/store/lw5mv8qzyalks7w80a6615na48i8lny1-gtk-doc-1.33.2/bin:/nix/store/n48i43wkly6kfhxz4ypcxbsv2pr7ggzh-perl-5.36.0/bin:/nix/store/zms41v0fgzfq4z629kn5jrlcv7hf9w7v-gettext-0.21/bin:/nix/store/3qgzjk0i8g7gif5jly94nbph0jwx4d0s-gobject-introspection-wrapped-1.74.0-dev/bin:/nix/store/02ggkplpkvdjkr20bylnidhn7cyh66m4-glib-2.74.3-dev/bin:/nix/store/k886wb6j8m1jwxf5pf1d5mdmlyblyd1y-glib-2.74.3-bin/bin:/nix/store/g2nfbpind37b3v3y6zbszmcgfmrj5v7x-patchelf-0.15.0/bin:/nix/store/wn31i3dzwahz6ccws8bs1nwyqrpgsvj7-gcc-wrapper-11.3.0/bin:/nix/store/sxdx80lmk4zkhb51f4x5dgqvxgmx55wl-gcc-11.3.0/bin:/nix/store/s7ip867mrpnnjlppbnxlcsq10gv13x2x-glibc-2.35-224-bin/bin:/nix/store/h8gvq6r4hgpa71h44dmg9qfx03mj81sv-coreutils-9.1/bin:/nix/store/62fb427ncxaaksa2k59rhbilfg68v20x-binutils-wrapper-2.39/bin:/nix/store/frh9l9nrdysasdi2gs7i241s241ngjw2-binutils-2.39/bin:/nix/store/w73bxii8xlsm9459628glawfcjlci75d-gobject-introspection-1.74.0-dev/bin:/nix/store/h8gvq6r4hgpa71h44dmg9qfx03mj81sv-coreutils-9.1/bin:/nix/store/zml88vnkpm8if114qkbbqd1q7n3ypqqy-findutils-4.9.0/bin:/nix/store/49y3r0gr9m6k20d91kl6dgp4b9a6m72v-diffutils-3.8/bin:/nix/store/5dv5cq1lwvsijr9p16p2kp79g1dbajk3-gnused-4.8/bin:/nix/store/bcvccw6y9bfil6xrl5j7psza7hnd16ry-gnugrep-3.7/bin:/nix/store/l1fp0hyca54xbb85vfhppd16bskzx8dg-gawk-5.1.1/bin:/nix/store/89zbjdkb48ma61k76l2mzn3s0ra0wn2c-gnutar-1.34/bin:/nix/store/qs8qb1swpivkfq7i9yd52n0mw6z4ij81-gzip-1.12/bin:/nix/store/wwkyfg8b34xy16zzc9p6rkh59p4q37qx-bzip2-1.0.8-bin/bin:/nix/store/i0x4pzj96qwvkrm94317l6jbi53a2rdj-gnumake-4.4/bin:/nix/store/4xw8n979xpivdc46a9ndcvyhwgif00hz-bash-5.1-p16/bin:/nix/store/793iwfbjvg7wgpqq7r83a1qjl1yg02sf-patch-2.7.6/bin:/nix/store/a3mwv26f99ycsv9w6hrx0jjjjywvcb1n-xz-5.2.9-bin/bin:/nix/store/camlh5laf1wsklghk0vcaw7gvx4rpzd1-file-5.43/bin"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if someone does this then the fake-uname won't be used but if coreutils is after fake-uname then the fake is used
diff --git a/pkgs/development/libraries/libgtop/default.nix b/pkgs/development/libraries/libgtop/default.nix
index 59db7929240..8a256e5f811 100644
--- a/pkgs/development/libraries/libgtop/default.nix
+++ b/pkgs/development/libraries/libgtop/default.nix
@@ -8,6 +8,7 @@
, gnome
, gtk-doc
, fake-uname
+, coreutils
}:
stdenv.mkDerivation rec {
@@ -27,6 +28,7 @@ stdenv.mkDerivation rec {
perl
gettext
gobject-introspection
+ coreutils
fake-uname
];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or possibly when one of the preceding dependencies propagates it?
@@ -26,6 +27,7 @@ stdenv.mkDerivation rec { | |||
perl | |||
gettext | |||
gobject-introspection | |||
fake-uname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There needs to be a comment that this is to ensure reproducibility. Ideally with some details so that the necessity can be judged in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe fake-uname
should be called deterministic-uname
or uname-deterministic
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chose deterministic-uname
and added details as a comment
3afdebf
to
20cde9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently github no longer lets you leave resolvable comments without a "header" comment? A glitch in the matrix.
20cde9e
to
e1c44f1
Compare
e1c44f1
to
4f6c076
Compare
4f6c076
to
32d00c8
Compare
for reproducibility deterministic-uname: dont hardcode OPERATING_SYSTEM_VAL to GNU/Linux
this will make the build reproducible libgtop_server2 contained Linux 5.15.68 x86_64 This libgtop was compiled on %s %s %s
32d00c8
to
faee5b0
Compare
# uname -o | ||
# maybe add to lib/systems/default.nix uname attrset | ||
# https://github.com/coreutils/coreutils/blob/7fc84d1c0f6b35231b0b4577b70aaa26bf548a7c/src/uname.c#L373-L374 | ||
# 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 | ||
operatingSystem = | ||
if stdenv.buildPlatform.isLinux | ||
then "GNU/Linux" | ||
else if stdenv.buildPlatform.isDarwin | ||
then "Darwin" # darwin isn't in host-os.m4 so where does this come from? | ||
else "unknown"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this
sidenote coreutils uname has basic supports for env vars but only on darwin since coreutils/coreutils@e3d1ff0 |
This seems to have broken the tarball job:
|
modDirVersion = if modDirVersion != "" then modDirVersion else "unknown"; | ||
|
||
meta = with lib; { | ||
description = "Print certain system information (hardcoded with <nixpkgs/lib/system> values)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajs124 it's catching the <> here, it should be changed to with lib/system values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo -n "$KERNEL_NAME_VAL $NODENAME_VAL $KERNEL_RELEASE_VAL $KERNEL_VERSION_VAL $MACHINE_VAL" | ||
# in help: except omit -p and -i if unknown. | ||
#echo -n "$PROCESSOR_VAL $HARDWARE_PLATFORM_VAL\n" | ||
echo -n "$OPERATING_SYSTEM_VAL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace is missing:
$ nix shell nixpkgs#deterministic-uname -c uname -a
Linux nixpkgs unknown #1-NixOS Tue Jan 1 00:00:00 UTC 1980 x86_64GNU/Linux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks fix in #213768
Would be awesome if this could be used in low-level packages (perl for example, adding |
for that we need to get rid of the coreutils and getopt dependencies or do something with bootstrapTools |
for reproducibility
based on #64258
Closes #140175 and probably more
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes