Skip to content

elixir: enable Erlang compiler option - deterministic#271350

Merged
happysalada merged 1 commit intoNixOS:masterfrom
plastic-forks:zd/deterministic-elixir
Dec 2, 2023
Merged

elixir: enable Erlang compiler option - deterministic#271350
happysalada merged 1 commit intoNixOS:masterfrom
plastic-forks:zd/deterministic-elixir

Conversation

@c4710n
Copy link
Contributor

@c4710n c4710n commented Dec 1, 2023

Description of changes

This PR is trying to:

  • remove all non-deterministic information from Elixir builds:

    • As the Erlang compiler doc said, the deterministic compiler option:

    Omit the options and source tuples in the list returned by Module:module_info(compile), and reduce the paths in stack traces to the module name alone. This option will make it easier to achieve reproducible builds.

    • due to the reproducible nature of Nix, I don't provide an option to disable this.
  • improve the way to pass ERL_COMPILER_OPTIONS:

    • if we search ERL_COMPILER_OPTIONS, we will find this line.
    • and, ERLC_OPTS is the standard way to pass Erlang compiler options when building Elixir.
    • above mentioned line has already existed for 4 years, so there shouldn't be any compatibility issues. (The minimum version of Elixir supported by nixpkgs is 1.10, which is released at 2020/01/27)

Before this PR:

$ nix build .#legacyPackages.x86_64-darwin.elixir

$ rg "/nix/store/.*/erlang" result --files-with-matches --binary
result/lib/elixir/lib/elixir/ebin/elixir_parser.beam

# The BEAM file contains a source path to /nix/store/*erlang, which undermines the 
# benefits brought by mix release.
#
# Because, the elixir itself always references to erlang, due to Automatic Runtime 
# Dependencies, Erlang is always included as a runtime dependency.
#
# But, Erlang shouldn't be a runtime dependency when using mix release.

After this PR:

$ nix build .#legacyPackages.x86_64-darwin.elixir

$ rg "/nix/store/.*/erlang" result --files-with-matches --binary
# no more files referencing erlang. ;)

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Priorities

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: erlang General-purpose, concurrent, functional high-level programming language label Dec 1, 2023
@c4710n c4710n force-pushed the zd/deterministic-elixir branch from 4811cd0 to e5250bb Compare December 1, 2023 03:35
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Dec 1, 2023
@happysalada
Copy link
Contributor

This looks really good, thank you !

Im leaving this open for a little longer just in case someone wants to have a look at it.

@ankhers
Copy link
Contributor

ankhers commented Dec 1, 2023

Looks good. Thank you for this!

@happysalada happysalada merged commit 1b45f71 into NixOS:master Dec 2, 2023
c4710n added a commit to nix-giant/beam-utils that referenced this pull request Dec 3, 2023
@c4710n c4710n deleted the zd/deterministic-elixir branch December 3, 2023 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: erlang General-purpose, concurrent, functional high-level programming language 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants