Latex "\today" macro expands to December 31st, 1979

With latex installed through the nix package manager (on nixos), \today always expands to December 31st, 1979 instead of the current date. How can I get this to give return the correct date? Files corrected with nix build users have modification times of that date too so is this related?


Create a directory and add the mwe.tex and flake.nix (based off Exploring Nix Flakes: Build LaTeX Documents Reproducibly).

– mwe.tex –




– mwe.tex ends here –

– flake.nix –

  description = "MWE for reproducing \\today macro problem";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
        pkgs = nixpkgs.legacyPackages.${system};
        tex = pkgs.texlive.combine {
          inherit (pkgs.texlive) scheme-minimal latex-bin latexmk;
      in rec {
        packages = {
          document = pkgs.stdenvNoCC.mkDerivation rec {
            name = "mwe";
            src = self;
            buildInputs = [ pkgs.coreutils tex ];
            phases = [ "unpackPhase" "buildPhase" "installPhase" ];
            buildPhase = ''
              export PATH="${pkgs.lib.makeBinPath buildInputs}";
              mkdir -p .cache/texmf-var
              env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \
                latexmk -pdf -lualatex mwe.tex
            installPhase = ''
              mkdir -p $out
              cp mwe.pdf $out/
        defaultPackage = packages.document;

– flake.nix ends here –

Then run nix build "." in the new directory. The results should be a pdf containing December 31, 1979 (or when I just ran this I actually got January 1, 1980). I get the same problem when running latexmk as myself at the command line so it’s not only when the file is compiled by a nix build user.j

I have latex install using home-manager (package texlive.combined.scheme-full). I tried your tex file and it’s not happening. The PDF contains December 16, 2021. I compiled using pdflatex.

Tried it with pdflatex and xelatex and date is correct for both. Might be a problem with lualatex and not nix then.

I read the article you linked, you have to export SOURCE_DATE_EPOCH:

# self.lastModified is the date of last commit
SOURCE_DATE_EPOCH=${toString self.lastModified}


# a date you want
SOURCE_DATE_EPOCH=$(date -d "2021-11-30" +%s)
1 Like

That’s embarrassing. Thank you for pointing that out.

Hosted by Flying Circus.