{"id":13349607,"url":"https://github.com/arnarg/nix-gleam","last_synced_at":"2025-03-12T09:32:40.200Z","repository":{"id":189260790,"uuid":"627840291","full_name":"arnarg/nix-gleam","owner":"arnarg","description":"Generic nix builder for gleam applications","archived":false,"fork":false,"pushed_at":"2024-06-06T10:47:48.000Z","size":8,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-24T20:17:35.450Z","etag":null,"topics":[],"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/arnarg.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-14T10:10:23.000Z","updated_at":"2024-09-30T23:07:01.000Z","dependencies_parsed_at":"2024-05-06T12:57:56.684Z","dependency_job_id":"fd161727-ae70-4ec2-90ae-ca5c7a831263","html_url":"https://github.com/arnarg/nix-gleam","commit_stats":null,"previous_names":["arnarg/nix-gleam"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnarg%2Fnix-gleam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnarg%2Fnix-gleam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnarg%2Fnix-gleam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnarg%2Fnix-gleam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnarg","download_url":"https://codeload.github.com/arnarg/nix-gleam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243191623,"owners_count":20251089,"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":[],"created_at":"2024-07-29T20:02:13.856Z","updated_at":"2025-03-12T09:32:39.940Z","avatar_url":"https://github.com/arnarg.png","language":"Nix","funding_links":[],"categories":["Programming Languages"],"sub_categories":["Gleam"],"readme":"# nix-gleam\n\nGeneric nix builder for gleam applications.\n\nGleam will create a `manifest.toml` file for every project which acts as a lock file and contains package name, version and a sha256 checksum of the package for every dependency. This is enough info for the builder to fetch all dependencies using `fetchHex` in nix.\n\n## Usage\n\nCurrently there is only 1 builder which builds a gleam application and supports both `erlang` and `javascript` target (but hard-coded to use nodejs runtime).\n\n### buildGleamApplication\n\nIn `flake.nix`:\n\n```nix\n{\n  description = \"My gleam application\";\n\n  inputs.nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n  inputs.flake-utils.url = \"github:numtide/flake-utils\";\n  inputs.nix-gleam.url = \"github:arnarg/nix-gleam\";\n\n  outputs = {\n    self,\n    nixpkgs,\n    flake-utils,\n    nix-gleam,\n  }: (\n    flake-utils.lib.eachDefaultSystem\n    (system: let\n      pkgs = import nixpkgs {\n        inherit system;\n        overlays = [\n          nix-gleam.overlays.default\n        ];\n      };\n    in {\n      packages.default = pkgs.buildGleamApplication {\n        # The pname and version will be read from the `gleam.toml`\n        # file generated by gleam.\n        # But this can be overwritten here too:\n        # pname = \"my-app\";\n        # version = \"1.2.3\";\n\n        # The target is read from the `gleam.toml` file too.\n        # Default is \"erlang\" if nothing is specified but\n        # this can also be overwritten here too:\n        # target = \"javascript\";\n\n        # Erlang package can be overridden but defaults to\n        # `pkgs.erlang`.\n        # erlangPackage = pkgs.erlang_nox;\n\n        src = ./.;\n      };\n    })\n  );\n}\n````\n\n## Examples\n\n### Monorepo\n\nIn a monorepo example where sub-directories `backend`, `frontend` and `shared` are all different gleam packages where `backend` and `frontend` have a local path dependency `shared`, the following `flake.nix` can be used in the root of the monorepo.\n\n```nix\n{\n  description = \"My gleam monorepo\";\n\n  inputs.nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n  inputs.flake-utils.url = \"github:numtide/flake-utils\";\n  inputs.nix-gleam.url = \"github:arnarg/nix-gleam\";\n\n  outputs = {\n    self,\n    nixpkgs,\n    flake-utils,\n    nix-gleam,\n  }: (\n    flake-utils.lib.eachDefaultSystem\n    (system: let\n      pkgs = import nixpkgs {\n        inherit system;\n        overlays = [\n          nix-gleam.overlays.default\n        ];\n      };\n    in {\n      packages = {\n        # Backend application\n        backend = pkgs.buildGleamApplication {\n          src = ./backend;\n          # Inform the builder to use `./shared`\n          # as a local package.\n          localPackages = [./shared];\n        };\n        # Frontend application\n        frontend = pkgs.buildGleamApplication {\n          src = ./frontend;\n          # Inform the builder to use `./shared`\n          # as a local package.\n          localPackages = [./shared];\n        };\n      };\n    })\n  );\n}\n```\n\n### Rebar3 plugins\n\nSome dependencies will take in erlang dependencies that might need rebar3 plugins to build and will produce build errors like:\n```\nErrors loading plugin pc. Run rebar3 with DEBUG=1 set to see errors.\n```\n\nIn such cases rebar3 package used in the build can be overwritten with `rebar3Package`.\n\n```nix\n{\n  description = \"My gleam application\";\n\n  inputs.nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n  inputs.flake-utils.url = \"github:numtide/flake-utils\";\n  inputs.nix-gleam.url = \"github:arnarg/nix-gleam\";\n\n  outputs = {\n    self,\n    nixpkgs,\n    flake-utils,\n    nix-gleam,\n  }: (\n    flake-utils.lib.eachDefaultSystem\n    (system: let\n      pkgs = import nixpkgs {\n        inherit system;\n        overlays = [\n          nix-gleam.overlays.default\n        ];\n      };\n    in {\n      packages.default = pkgs.buildGleamApplication {\n        src = ./.;\n\n        # Overrides the rebar3 package used, adding\n        # plugins using `rebar3WithPlugins`.\n        rebar3Package = pkgs.rebar3WithPlugins {\n          plugins = with pkgs.beamPackages; [pc];\n        };\n      };\n    })\n  );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnarg%2Fnix-gleam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnarg%2Fnix-gleam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnarg%2Fnix-gleam/lists"}