NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.73k stars 13.86k forks source link

Make `stdenv` setup time (SOURCE_DATE_EPOCH) use POSIX compliant ref #241522

Closed sambacha closed 1 year ago

sambacha commented 1 year ago

SOURCE_DATE_EPOCH

IEEE Std 1003.1-1988 (POSIX.1) legislates that a time_t value of 536457599 SHALL correspond to "Wed Dec 31 23:59:59 GMT 1986."

https://github.com/NixOS/nixpkgs/blob/9fa6434de950a688b190694b5635fc2cd0c73dbc/pkgs/stdenv/generic/setup.sh#L407

It is important that the interpretation of time names and seconds since the Epoch values be consistent across conforming systems. That is, it is important that all conforming systems interpret " 536457599 seconds since the Epoch" as 59 seconds, 59 minutes, 23 hours 31 December 1986 , regardless of the accuracy ~ IEEE Std 1003.1-1988[^1]

[^1]: Federal Information Processing Standards Publication: IEEE standard portable operating system interface for computer environments

Suggestion

- : "${SOURCE_DATE_EPOCH:=315532800}" 
+ : "${SOURCE_DATE_EPOCH:=536457599}"

Note Also notwithstanding the current usage is also incorrect, https://reproducible-builds.org/docs/source-date-epoch/ and https://wiki.debian.org/ReproducibleBuilds/StandardEnvironmentVariables#Checklist

Other examples

Bazel^2

static const u4 kDefaultTimestamp =
    30 << 25 | 1 << 21 | 1 << 16;  // January 1, 2010 in DOS time

NPM^3

+   // Provide a specific date in the 1980s for the benefit of zip,
+   // which is confounded by files dated at the Unix epoch 0.
+    mtime: new Date('1985-10-26T08:15:00.000Z'),

Time_Circuits_BTTF

Debian Packaging^4

'2017-05-08T00:00:00Z' stretch

Artturin commented 1 year ago

It is important that the interpretation of time names and seconds since the Epoch values be consistent across conforming systems. That is, it is important that all conforming systems interpret " 536457599 seconds since the Epoch" as 59 seconds, 59 minutes, 23 hours 31 December 1986 , regardless of the accuracy ~ IEEE Std 1003.1-19881

this just means 536457599 seconds since the Epoch == 59 seconds, 59 minutes, 23 hours 31 December 1986 so not related to SOURCE_DATE_EPOCH. We're not interpreting epoch values