{"id":16406433,"url":"https://github.com/axelf4/nix-rebar3","last_synced_at":"2025-10-26T17:31:40.095Z","repository":{"id":45030833,"uuid":"510138812","full_name":"axelf4/nix-rebar3","owner":"axelf4","description":"Nix library for building rebar3 projects","archived":false,"fork":false,"pushed_at":"2023-01-08T09:18:59.000Z","size":67,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T21:53:19.684Z","etag":null,"topics":["erlang","nix","rebar3"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axelf4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-03T21:26:00.000Z","updated_at":"2023-05-04T12:51:03.000Z","dependencies_parsed_at":"2023-02-08T05:31:28.845Z","dependency_job_id":null,"html_url":"https://github.com/axelf4/nix-rebar3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelf4%2Fnix-rebar3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelf4%2Fnix-rebar3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelf4%2Fnix-rebar3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelf4%2Fnix-rebar3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axelf4","download_url":"https://codeload.github.com/axelf4/nix-rebar3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375271,"owners_count":19461573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","nix","rebar3"],"created_at":"2024-10-11T06:09:45.991Z","updated_at":"2025-10-26T17:31:39.773Z","avatar_url":"https://github.com/axelf4.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nix-rebar3\n\nThis is a Nix library aiming to be an alternative to [rebar3_nix] that\ndoes not require code generation, similar to [mix-to-nix] but for\nrebar3 instead of Mix.\n\n## Usage\n\n```nix\n(callPackage nix-rebar3 {}).buildRebar3 {\n  root = ./.;\n  pname = \"myapp\";\n  version = \"1.0.0\";\n  releaseType = \"release\";\n  profile = \"prod\";\n}\n```\n\nNote that for running a built release with [dynamic configuration] you\neither need to first copy the files out of the read-only Nix store, or\nset the `RELX_OUT_FILE_PATH` environment variable to a suitable\nlocation, since the extended start script generated by [relx] by\ndefault will write files under the release root directory.\n\nThe parameters of `buildRebar3` are:\n\n| Attribute | Description |\n| --- | --- |\n| `pname` | The name of the derivation. |\n| `version` | The version number. |\n| `root` | Path to the directory of the rebar3 project. |\n| `releaseType` | One of: `app` to build OTP applications; `release` to assemble relx releases; or `escriptize` to generate an escript executable. (Default: `app`) |\n| `profile` | The profile to run rebar3 tasks in. (Default: `default`) |\n| `checkouts` | Attribute set where the keys are dependency names and values are paths to their sources.\u003cbr /\u003eThis is for overriding dependencies or providing the transitive closure of dependencies such as plugins or those not in the `default` profile, e.g. test dependencies. The latter is made necessary by such dependencies not being stored in the rebar3 lock file. (Default: `{}`)  |\n| `singleStep` | Whether to skip compiling the dependencies in an intermediate derivation first. Enabling reduces the incrementality of builds. (Default: `false`) |\n\nAll other arguments are passed through to the resulting `stdenv.mkDerivation` call.\n\n## Background\n\nThis section summarizes the existing support for packaging rebar3\nprojects in Nixpkgs. Apart from the regular `nixpkgs.rebar3`\nattribute, which is adequate for interactive usage, there is also a\npatched version that makes it possible to provide paths to pre-built\nrebar3 plugins to include with\n\n    nixpkgs.rebar3WithPlugins { plugins = [ ... ] }\n\t\n(which passes them through an internal `REBAR_GLOBAL_PLUGINS`\nenvironment variable) to avoid rebar3 choking on trying to download\nmissing plugins during sandboxed builds. When using\n`rebar3WithPlugins`, in addition to manually specified plugins, a\ncustom [`rebar_ignore_deps`][rebar_ignore_deps.erl] is always\nincluded, that, when the environment variable `REBAR_IGNORE_DEPS` is\nnon-empty, overrides the `install_deps` rebar3 provider to instead\nproceed with the build as if there were no declared dependencies.\n\nThere are choices that can be made when packaging rebar3 projects with\nNix in general regarding library Erlang application dependencies. They\nmay be built en masse in a separate derivation, or individually with\none derivation each. To prevent Rebar3 from managing and downloading\nthe dependencies, one can either: Copy them into the\n[`_checkouts`][Checkout Dependencies] top-level directory; or\nreference built library dependencies in the [`ERL_LIBS`][Code Path]\nenvironment variable, and use the [`bare\ncompile`][rebar_prv_bare_compile.erl] rebar3 provider instead of\n`compile` (which skips trying to build dependencies,) or set\n`REBAR_IGNORE_DEPS` to true (see above.) Note that it is not possible\nto include multiple versions of the same application in Erlang/rebar3;\nthe lock file in the top level project is authoritative, with an\nalgorithm for determining the versions to fetch, see [Source\nDependencies]; and rebar3 plugins may technically interfere when\nbuilding other dependencies; and therefore building libraries\nindividually can produce unexpected results.\n\nWith that said, the available rebar3 builders in Nixpkgs are:\n\n* [`buildRebar3`][build-rebar3.nix]: Builds Erlang applications using\n  `rebar3 bare compile`.\n\n  The built package will export a [setup hook][Package setup hooks]\n  that adds the built applications to `ERL_LIBS`. All dependencies\n  have to be built similarly and passed in the `beamDeps` argument,\n  which due to the setup hooks is here just an alias for\n  `propagatedBuildInputs`.\n* [`rebar3Relx`][rebar3-release.nix]: Builds relx releases or escript\n  executables.\n\n  Dependencies should be provided with `beamDeps` like above, at which\n  point `REBAR_IGNORE_DEPS` is set.\n* [`fetchRebar3Deps`][fetch-rebar-deps.nix]: Produces a fixed-output\n  derivation (FOD) with the output of `rebar3 get-deps`.\n  \n  The result can be used as the `checkouts` argument to `rebar3Relx`.\n* [`fetchHex`][fetch-hex.nix]: Fetches a package tarball from [Hex]\n  the Erlang package manager/repository.\n  \n  [`buildHex`][build-hex.nix] is a shorthand for using `fetchHex` for\n  the source to any other builder such as `buildRebar3`.\n  \nrebar3_nix is a tool that generates a `deps.nix` file you are intended\nto check in to version control, which evaluates to an attribute set\ncontaining all dependencies for some rebar3 project. Rebar3 lock files\nare limited to the `default` profile, and do not include plugin\ndependencies nor the precise subdependencies of some dependency, but,\nbeing a rebar3 plugin, rebar3_nix has access to that information and\nfor any combination of profiles.\n\nThis library instead reads the rebar3 lock file with a pure Nix\nparser, with the big upside of not requiring any additional generated\nfiles. The downsides are that compiled dependencies are not shared\nbetween different projects built with Nix, and that plugins and\ndependencies not listed in the `default` profile, such as `test`\ndependencies, and their transitive dependencies, have to be specified\nmanually.\n\n[rebar3_nix]: https://github.com/erlang-nix/rebar3_nix\n[mix-to-nix]: https://github.com/transumption/mix-to-nix\n[relx]: http://erlware.github.io/relx/\n[Dynamic Configuration]: https://rebar3.readme.io/docs/releases#dynamic-configuration\n[Source Dependencies]: https://rebar3.readme.io/docs/dependencies#source-dependencies\n[Checkout Dependencies]: https://rebar3.readme.io/docs/dependencies#checkout-dependencies\n[Code Path]: https://www.erlang.org/doc/man/code.html#code-path\n[rebar_ignore_deps.erl]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/build-managers/rebar3/rebar_ignore_deps.erl\n[rebar_prv_bare_compile.erl]: https://github.com/erlang/rebar3/blob/main/apps/rebar/src/rebar_prv_bare_compile.erl\n[build-rebar3.nix]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/build-rebar3.nix\n[rebar3-release.nix]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/rebar3-release.nix\n[fetch-rebar-deps.nix]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/fetch-rebar-deps.nix\n[fetch-hex.nix]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/fetch-hex.nix\n[build-hex.nix]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/build-hex.nix\n[Hex]: https://hex.pm/\n[Package setup hooks]: https://nixos.org/manual/nixpkgs/stable/#ssec-setup-hooks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelf4%2Fnix-rebar3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxelf4%2Fnix-rebar3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelf4%2Fnix-rebar3/lists"}