{"id":13631175,"url":"https://github.com/inscapist/ruby-nix","last_synced_at":"2026-02-24T12:00:57.548Z","repository":{"id":65103063,"uuid":"580308156","full_name":"inscapist/ruby-nix","owner":"inscapist","description":"Generates reproducible ruby/bundler app environment with Nix","archived":false,"fork":false,"pushed_at":"2025-08-13T04:24:12.000Z","size":174,"stargazers_count":139,"open_issues_count":8,"forks_count":14,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-08-13T06:23:46.630Z","etag":null,"topics":["bundix","nix","nix-flake","ruby","ruby-nix"],"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/inscapist.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,"zenodo":null}},"created_at":"2022-12-20T08:37:50.000Z","updated_at":"2025-08-13T04:24:15.000Z","dependencies_parsed_at":"2024-01-19T15:28:20.137Z","dependency_job_id":"a8cd21ce-5e97-4e9a-aeb8-53da1b52fbb7","html_url":"https://github.com/inscapist/ruby-nix","commit_stats":{"total_commits":125,"total_committers":5,"mean_commits":25.0,"dds":0.06399999999999995,"last_synced_commit":"1f3756f8a713171bf891b39c0d3b1fe6d83a4a63"},"previous_names":["inscapist/ruby-nix","sagittaros/ruby-nix"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/inscapist/ruby-nix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inscapist%2Fruby-nix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inscapist%2Fruby-nix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inscapist%2Fruby-nix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inscapist%2Fruby-nix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inscapist","download_url":"https://codeload.github.com/inscapist/ruby-nix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inscapist%2Fruby-nix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29781196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T10:45:18.109Z","status":"ssl_error","status_checked_at":"2026-02-24T10:45:09.911Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bundix","nix","nix-flake","ruby","ruby-nix"],"created_at":"2024-08-01T22:02:13.854Z","updated_at":"2026-02-24T12:00:57.542Z","avatar_url":"https://github.com/inscapist.png","language":"Nix","funding_links":[],"categories":["Nix","Programming Languages"],"sub_categories":["Ruby"],"readme":"# Ruby Nix\n\nThis is technically a fork of `bundlerEnv` that attempts to better meet the needs of ruby app developers instead of package maintainers.\n\nThis flake exports a function that is suitable for application development (eg. Rails).\n\n## Tl;dr\nThe `gemset.nix` file, generated by executing the `bundix` command, manages your environment. Bundix depends on the contents of `Gemfile.lock`, which is produced by running the `bundle lock` command after modifying the `Gemfile`.\n\n```\nGemfile --[bundle lock]--\u003e\nGemfile.lock --[bundix]--\u003e\ngemset.nix --[nix develop (actual build)]--\u003e\nreproducible ruby environment\n```\n\n## Features\n\n1. supports local, path-based gems\n2. supports git sources\n3. supports pre-compiled native gems on multiple platforms (see [this discussion](https://github.com/nix-community/bundix/pull/68))\n4. bundix out of the box\n5. A starter template based on flake\n\n## How is it different from bundlerEnv?\n\n1. it does not track the entire directory as `inputSrc` when `gemDir` is specified, requiring only `gemset.nix`.\n2. it does not use `BUNDLE_GEMFILE` variable.\n3. it works without `Gemfile` and `Gemfile.lock`.\n\n## The gist\n\n``` nix\n      let\n        pkgs = import nixpkgs {\n          inherit system;\n          overlays = [ ruby-nix.overlays.ruby ];\n        };\n        rubyNix = ruby-nix.lib pkgs;\n\n        inherit (rubyNix {\n          name = \"simple-ruby-app\";\n          gemset = ./gemset.nix;\n        })\n          env ruby;\n      in {\n        devShells = rec {\n          default = dev;\n          dev = pkgs.mkShell { buildInputs = [ env ruby ]; };\n        };\n      });\n```\n\n## Global Bundix Installation (optional)\n\nMy bundix [fork](https://github.com/inscapist/bundix) is needed to generate the correct `gemset.nix`. It is available in nix shell out of the box. \n\n\n``` sh\n# installation\nnix profile install github:inscapist/bundix/main\n\n# upgrade\nnix profile upgrade '.*'\n```\n\n## Usage\n\nWith nix [installed](/docs/nix-installation.md) and optionally [direnv](/docs/direnv.md), you can run:\n\n#### 1. Initialize flake\n\n``` sh\ncd myapp\nnix flake init -t github:inscapist/ruby-nix/main\n```\n\n#### 2. Enter nix shell\n\nIf you are a [direnv](/docs/direnv.md) user, add the following content to `.envrc` and run `direnv allow`. Otherwise, run `nix develop -c zsh`.\n\n```\nif ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then\n    source_url \"https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc\" \"sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=\"\nfi\n\nwatch_file gemset.nix\nuse flake\n```\n\nOr use the latest version [here](https://github.com/nix-community/nix-direnv/blob/master/templates/flake/.envrc). Don't forget to add `watch_file /path_to/gemset.nix` to ensure direnv picks up gem changes.\n\n#### 3. In nix shell\n\nIn a nix shell, you have `ruby`, `irb`, `bundle` at your disposal. Additional gems will only be available if they are specified in `gemset.nix`. To generate that, ensure `Gemfile` and `Gemfile.lock` are present, then run `bundix`. \n\n## FAQs\n\n### 1. When does my environment gets build?\nIf you use direnv, running `git add gemset.nix` would trigger a rebuild automatically.\n\nOtherwise, Ctrl-D to exit the current nix shell, and enter again.\n\n\n### 2. How to `bundle`?\n\nWith ruby-nix, you shouldn't install gems using bundle. Nix will build the gems for you. **Always run `bundix` to update your gemset after making changes to Gemfile.lock.**. If you faced error with `git fetch`, set `BUNDLE_PATH=vendor/bundle` in your environment.\n\n#### bundle add\nrun `bundle add GEM --skip-install` instead\n\n#### bundle install (after modifying Gemfile)\nrun `bundle lock` instead\n\n#### bundle update GEM\nrun `bundle lock --update=GEM` instead\n\n#### Adding multiple platforms to Gemfile.lock\n\nOne example could be:\n\n``` sh\nbundle lock --update --add-platform ruby arm64-darwin-21 x86_64-darwin-20 x86_64-linux\n```\n\nYou can retrieve the platform names by running `bundle platform`. Having multiple platforms would allow your colleagues to use precompiled gems, if they are available.\n\nIn your Gemfile.lock, it should show up as:\n```\n   sorbet-runtime (0.5.10626)\n    sorbet-static (0.5.10626-universal-darwin-20)\n    sorbet-static (0.5.10626-universal-darwin-21)\n    sorbet-static (0.5.10626-universal-darwin-22)\n    sorbet-static (0.5.10626-x86_64-linux)\n    sorbet-static-and-runtime (0.5.10626)\n      sorbet (= 0.5.10626)\n@@ -1232,6 +1233,7 @@ GEM\nPLATFORMS\n  arm64-darwin-20\n  arm64-darwin-21\n  arm64-darwin-22\n  x86_64-darwin-20\n  x86_64-darwin-21\n  x86_64-linux\n```\n### 3. `bundle lock` fails with `Permission denied` when Gemfile contains git sources\n\n``` sh\nexport BUNDLE_PATH=vendor/bundle \nbundle lock\nrm -rf vendor/bundle\n```\n\nalso remove or rename `.bundle` if it continues to fail.\n\n### 4. How to use a different ruby version?\n\nCode comment of [simple-app](examples/simple-app/flake.nix) shows how to use ruby_3_1 instead of the\n_current_ default version (2.7.6). You can also write your own overlay that overrides globally with your own ruby derivation.\n\n## Common issues\n\n#### I want to use a custom ruby version\nCheck the [sample](examples/simple-app/flake.nix). @bobvanderlinden maintains it at the [nixpkgs-ruby](https://github.com/bobvanderlinden/nixpkgs-ruby/tree/master) project.\n\n#### Local bundle config overriding environment\nCheck your `.bundle/config` \n\n#### Ruby or gems don't come from nix\nCheck that you have removed `.rbenv` or `.rvm`\n\n#### Bundle install doesn't work\nCheck the previous section. You should only use `bundler` to lock your dependencies, not install them.\n\n#### I don't like that `nix develop` is a bash shell\nUse `nix develop -c zsh` or even better install `.envrc`, following this guide.\n\n#### binstubs don't work, it is saying gems are missing\nadd this to the binstubs (ie \"bin/\u003cmy-gem\u003e\"). \n```\nENV[\"BUNDLE_IGNORE_CONFIG\"] = \"1\"\n```\n\nThis is because Bundler reads configuration from various sources (.bundle/config, ~/.bundle/config, and environment variables) that can interfere with how gems are located when the binstub runs.\n\n## Roadmap\n\n1. Try out more ruby versions, both old and new\n2. Make bundix runs faster\n3. More documentations\n\n## Credits\n\nAll credits goes to the original authors of `buildRubyGem`, `bundlerEnv`, and `bundix` (@manveru, @lavoiesl, @jdelStrother). This is only a thin layer with a different take on top of these solid foundation. \n\nPRs welcomed :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finscapist%2Fruby-nix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finscapist%2Fruby-nix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finscapist%2Fruby-nix/lists"}