{"id":14968069,"url":"https://github.com/mercurytechnologies/nix-your-shell","last_synced_at":"2026-01-16T12:51:09.263Z","repository":{"id":65801262,"uuid":"599799365","full_name":"MercuryTechnologies/nix-your-shell","owner":"MercuryTechnologies","description":"A `nix` and `nix-shell` wrapper for shells other than `bash`","archived":false,"fork":false,"pushed_at":"2024-09-24T17:23:10.000Z","size":143,"stargazers_count":161,"open_issues_count":8,"forks_count":12,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-02T21:51:49.858Z","etag":null,"topics":["nix","nixos"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/MercuryTechnologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-02-09T22:45:07.000Z","updated_at":"2025-03-31T07:07:31.000Z","dependencies_parsed_at":"2023-03-06T08:45:59.534Z","dependency_job_id":"947d9aed-51ac-42ee-bbd8-a9d4620c5b76","html_url":"https://github.com/MercuryTechnologies/nix-your-shell","commit_stats":{"total_commits":73,"total_committers":8,"mean_commits":9.125,"dds":"0.12328767123287676","last_synced_commit":"8d55e745700207b54f1432e942351881804b4721"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MercuryTechnologies%2Fnix-your-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MercuryTechnologies%2Fnix-your-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MercuryTechnologies%2Fnix-your-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MercuryTechnologies%2Fnix-your-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MercuryTechnologies","download_url":"https://codeload.github.com/MercuryTechnologies/nix-your-shell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980844,"owners_count":21027808,"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":["nix","nixos"],"created_at":"2024-09-24T13:39:11.863Z","updated_at":"2026-01-16T12:51:09.254Z","avatar_url":"https://github.com/MercuryTechnologies.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nix-your-shell\n\n[![nixpkgs](https://repology.org/badge/version-for-repo/nix_unstable/nix-your-shell.svg?header=nixpkgs)](https://repology.org/project/nix-your-shell/versions)\n[![Crates.io](https://img.shields.io/crates/v/nix-your-shell)](https://crates.io/crates/nix-your-shell)\n\nA `nix` and `nix-shell` wrapper for shells other than `bash`.\n\n`nix develop` and `nix-shell` use `bash` as the default shell, so\n`nix-your-shell` prints shell snippets you can source to use the shell\nyou prefer inside of Nix shells.\n\n## Usage\n\n`nix-your-shell` will print out shell environment code you can source to\nactivate `nix-your-shell`. For example:\n\n```ShellSession\n$ nix-your-shell fish\n# If you see this output, you probably forgot to pipe it into `source`:\n# nix-your-shell fish | source\n\nfunction nix-shell --description \"Start an interactive shell based on a Nix expression\"\n    nix-your-shell fish nix-shell -- $argv\nend\n\nfunction nix --description \"Reproducible and declarative configuration management\"\n    nix-your-shell fish nix -- $argv\nend\n```\n\nThese replace commands like `nix foo bar` with `nix-your-shell fish nix foo\nbar`. `nix-your-shell` then parses the `nix` arguments and adds a `--command\nfish` argument before launching the underlying command.\n\nThen, `nix-shell`, `nix develop`, and `nix shell` will use your shell instead\nof bash, unless overridden explicitly with a `--command` argument.\n\n### Fish\n\nAdd to your `~/.config/fish/config.fish`:\n\n```fish\nif command -q nix-your-shell\n  nix-your-shell fish | source\nend\n```\n\n### Zsh\n\nAdd to your `~/.zshrc`:\n\n```zsh\nif command -v nix-your-shell \u003e /dev/null; then\n  nix-your-shell zsh | source /dev/stdin\nfi\n```\n\n### Xonsh\n\nAdd to your `~/.xonshrc` or `~/.config/xonsh/rc.xsh`\n\n```xonsh\nexecx($(nix-your-shell xonsh))\n```\n\n### Nushell\n\n\u003e [!IMPORTANT]\n\u003e Nushell version \u003e=0.87.0 is required\n\n\u003e [!NOTE]\n\u003e Nushell requires configuration files to exist before `nu` is started.\n\nAdd to your `~/.config/nushell/config.nu`:\n\n```nu\noverlay use ~/.config/nushell/nix-your-shell.nu\n```\n\nTo generate the `nix-your-shell.nu` file:\n\nEither manually generate it:\n\n```nu\nnix-your-shell nu | save $env.XDG_CONFIG_HOME/nushell/nix-your-shell.nu\n```\n\nOr ensure it's kept updated alongside `nix-your-shell` by populating the file with [`home-manager`][home-manager]:\n\n[home-manager]: https://nix-community.github.io/home-manager/\n\n```nix\n{ config, pkgs, ... }: {\n  home.file.\"${config.xdg.configHome}/nushell/nix-your-shell.nu\".source = pkgs.nix-your-shell.generate-config \"nu\";\n}\n```\n\n## Installation\n\nYou can either install `nix-your-shell` from this repository or from `nixpkgs`.\nThe version packaged in `nixpkgs` will probably lag behind this repository by\nabout a week or so.\n\n### nix profile\n\nTo install the latest version with `nix profile`, use one of:\n\n```sh\nnix profile install github:MercuryTechnologies/nix-your-shell\nnix profile install \"nixpkgs#nix-your-shell\"\n```\n\n### nix-env\n\nTo install the latest version with `nix-env`, use one of:\n\n```sh\nnix-env --install --file https://github.com/MercuryTechnologies/nix-your-shell/archive/refs/heads/main.tar.gz\nnix-env --install nix-your-shell\n```\n\nYou can later remove the installed program with `nix-env --uninstall nix-your-shell`.\n\n### nix run\n\nRun dynamically with `nix run`:\n\n```sh\nnix run github:MercuryTechnologies/nix-your-shell -- zsh\nnix run \"nixpkgs#nix-your-shell\" -- zsh\n```\n\nNote that because the generated shell code will refer to the dynamically-built\n`nix-your-shell` executable, it may get [garbage\ncollected][nix-collect-garbage] and cause problems later.\n\n[nix-collect-garbage]: https://nixos.org/manual/nix/stable/package-management/garbage-collection.html\n\n### Flakes\n\n`nix-your-shell` is packaged in `nixpkgs`, so you can add `pkgs.nix-your-shell`\nto `environment.systemPackages` if you don't need the bleeding edge releases\nfrom this repo.\n\nAdd to a NixOS flake configuration using the overlay:\n\n`flake.nix`:\n\n```nix\n{\n  inputs = {\n    nixpkgs.url = \"github:NixOS/nixpkgs\";\n    nix-your-shell = {\n      url = \"github:MercuryTechnologies/nix-your-shell\";\n      inputs.nixpkgs.follows = \"nixpkgs\";\n    };\n  };\n\n  outputs = {\n    self,\n    nixpkgs,\n    ...\n  } @ attrs: {\n    nixosConfigurations = {\n      YOUR_HOSTNAME = nixpkgs.lib.nixosSystem {\n        system = \"x86_64-linux\";\n        specialArgs = attrs;\n        modules = [./YOUR_HOSTNAME.nix];\n      };\n    };\n  };\n}\n```\n\n`./YOUR_HOSTNAME.nix`:\n\n```nix\n{\n  config,\n  pkgs,\n  nix-your-shell,\n  ...\n}: {\n  nixpkgs.overlays = [\n    nix-your-shell.overlays.default\n  ];\n\n  environment.systemPackages = [\n    pkgs.nix-your-shell\n  ];\n\n  # Example configuration for `fish`:\n  programs.fish = {\n    enable = true;\n    interactiveShellInit = ''\n      nix-your-shell fish | source\n    '';\n  };\n\n  # ... extra configuration\n}\n```\n\n## Adding support for new shells\n\nSee [#23](https://github.com/MercuryTechnologies/nix-your-shell/pull/23) for an\nexample of adding support for a new shell to `nix-your-shell`.\n\n## Comparison with `any-nix-shell`\n\n[`any-nix-shell`](https://github.com/haslersn/any-nix-shell) does roughly the\nsame thing, and serves as the inspiration for `nix-your-shell`.\n\nThere are a few reasons I wrote `nix-your-shell` as a competitor:\n\n- `any-nix-shell` doesn't support Nix flakes through `nix develop`. `nix-your-shell` does.\n- `any-nix-shell` is a hodgepodge of shell scripts with multiple layers of\n  `eval` and templating, making hacking or modifying it challenging. In\n  contrast, `nix-your-shell` is written in Rust with a relatively\n  straightforward structure (the shell environment code generation command and\n  the `nix` wrappers are the same, so there's no need for dotfile executables\n  on your `$PATH`).\n\nHowever, `any-nix-shell` can optionally display the packages in the current\nshell on a righthand prompt. `nix-your-shell` does not support this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmercurytechnologies%2Fnix-your-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmercurytechnologies%2Fnix-your-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmercurytechnologies%2Fnix-your-shell/lists"}