Skip to content

Reproducible builds with pixi install and SOURCE_DATE_EPOCH #4969

Closed
conda/rattler
#2418

Description

@lucasbn

When installing a pixi environment in a docker image, I'm seeing that the layer hash changes on every build despite the contents of pixi.toml and pixi.lock not changing.

FROM ghcr.io/prefix-dev/pixi:0.59.0

# Set environment variables for reproducibility
ENV SOURCE_DATE_EPOCH=200001010000
ENV TZ=UTC
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONHASHSEED=0

COPY --chown=root:root --chmod=644 pixi.toml pixi.toml
COPY --chown=root:root --chmod=644 pixi.lock pixi.lock

# Run pixi install and then fix all timestamps and sort order issues
RUN pixi install --locked

When I change the pixi install command to:

RUN pixi install --locked \
    && find .pixi/ /root/.pixi/ /root/.cache/ -type f -exec touch -t 200001010000 {} + 2>/dev/null || true \
    && find .pixi/ /root/.pixi/ /root/.cache/ -type d -exec touch -t 200001010000 {} + 2>/dev/null || true \
    && find .pixi/ -name "*.pyc" -delete 2>/dev/null || true \
    && find /root/.pixi/ -name "*.pyc" -delete 2>/dev/null || true

The layer hash becomes consistent between builds for this minimal example. I've experimented with this in: https://github.com/lucasbn/reproducible-layers

Would it make sense for pixi to automatically respect the SOURCE_DATE_EPOCH environment variable so there is no need to override the timestamps?

What are the other requirements to achieve reproducible builds with pixi install? Is this something that can be done centrally within pixi?

Activity

  1. xhochy commented on Nov 24, 2025

    @xhochy
    Contributor

    The majority of files are actually extracted plainly from conda archives. Thus, I would actually think we should respect their original timestamps instead of always creating them with the current one.

  2. wolfv commented on Nov 24, 2025

    @wolfv
    Member

    Thanks for bringing this up. We could indeed try to do a better job at preserving timestamps from the conda package to the environment. However, there are files that we rewrite (to replace the PREFIX placeholder string). In that case, we could indeed use the SOURCE_DATE_EPOCH, or default to a constant date (birth date of pixi, or something).

  3. baszalmstra commented on Nov 28, 2025

    @baszalmstra
    Contributor

    Or could we reset the modified date maybe? Would that make sense?

  4. baszalmstra commented on Dec 17, 2025

    @baszalmstra
    Contributor

    @xhochy @wolfv does it make sense to reset the latest modified date to the original date in the archive?

  5. xhochy commented on Dec 17, 2025

    @xhochy
    Contributor

    Yes, that sounds like the expected behaviour.

  6. xhochy commented on Mar 18, 2026

    @xhochy
    Contributor

    Should this already be a in a pixi release? pixi=0.660 sadly doesn't seems to behave as promised.

  7. reopened this on Mar 18, 2026
  8. wolfv commented on Mar 18, 2026

    @wolfv
    Member

    Yes, I think it's a different issue than what we closed. Reopening!

  9. hunger commented on Mar 20, 2026

    @hunger
    Contributor

    Which filesystems are you running on? We try to set the mtime, but will not consider it an error if doing so fails, as users wanted to install to exfat drives.

  10. xhochy commented on Mar 23, 2026

    @xhochy
    Contributor

    I'm testing this on macOS (standard APFS) with

    pixi init
    pixi add openssl
    pixi install
    mv .pixi .pixi-a
    pixi install
    diffoscope .pixi .pixi-a
    
  11. hunger commented on Mar 27, 2026

    @hunger
    Contributor

    Thanks for getting back to this issue!

  12. hunger commented on May 8, 2026

    @hunger
    Contributor

    With these two changes pixi install && tar -czf pixi.tar .pixi will produce identical tarballs each time it is run (provided that pixi.lock does not change of course).

  13. reopened this on May 8, 2026
  14. hunger commented on May 18, 2026

    @hunger
    Contributor

    #6056 is about making a tarball of pixi envs reproducible and should finally fix this issue for good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions