{"id":22550944,"url":"https://github.com/mimvoid/nix-shells","last_synced_at":"2025-03-28T10:11:05.855Z","repository":{"id":265365900,"uuid":"881596176","full_name":"mimvoid/nix-shells","owner":"mimvoid","description":"A collection of little Nix shells for programs, aliases, and configs","archived":false,"fork":false,"pushed_at":"2024-12-29T17:18:44.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T10:34:33.819Z","etag":null,"topics":["container","nix","nix-flakes","nix-shell"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mimvoid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-10-31T22:13:41.000Z","updated_at":"2024-12-29T17:18:48.000Z","dependencies_parsed_at":"2024-11-29T09:33:53.125Z","dependency_job_id":null,"html_url":"https://github.com/mimvoid/nix-shells","commit_stats":null,"previous_names":["mimvoid/nix-shells"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimvoid%2Fnix-shells","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimvoid%2Fnix-shells/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimvoid%2Fnix-shells/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimvoid%2Fnix-shells/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mimvoid","download_url":"https://codeload.github.com/mimvoid/nix-shells/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246009078,"owners_count":20708881,"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":["container","nix","nix-flakes","nix-shell"],"created_at":"2024-12-07T17:09:07.199Z","updated_at":"2025-03-28T10:11:05.814Z","avatar_url":"https://github.com/mimvoid.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    mimvoid's little nix shells\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n    My personal collection of nix shell files for\n    temporary packages, shell functions, and configuration files.\n\u003c/p\u003e\n\n# Why?\n\nThere are certain tools I use repeatedly, but rarely enough that I don't want to keep\nthem in my user environment. For some, I may want settings and aliases that a simple\n`nix-shell` or `nix shell` command cannot provide.\n\nThe solution? Nix can use `shell.nix` files and `devShells` to symlink files\nand specify shell hooks. This repo is a collection of these files.\n\n\u003e [!NOTE]\n\u003e These shells are for my personal use cases. While I may listen to requests,\n\u003e this repository will likely be rather opinionated.\n\u003e\n\u003e I welcome anyone to create their own repo based on these files!\n\n# Usage\n\nThe shells can be entered with or without flakes.\n\n## With Flakes\n\nAt the root directory, use `nix develop` followed by the shell to enter.\nThe names of the `devShells` can be found in `flake.nix`.\n\n**Example:**\n\n`flake.nix`\n\n```nix\n{\n  # ... other file contents ...\n\n  outputs = { self, nixpkgs }:\n    # ...\n    devShells = forAllSystems ({ pkgs }: {\n      \"hello\" = import ./hello/shell.nix { inherit pkgs; };\n    });\n  };\n}\n```\n\n```sh\n$ nix develop .#hello\n```\n\nTo use a shell other than `bash`, you can do something like:\n\n```sh\n$ nix develop .#hello --command zsh\n```\n\n## With `nix-shell`\n\nEnter the directory with the `shell.nix` file you want to use, and do `nix-shell`.\n\n**Example:**\n\n```sh\n$ cd hello\n$ nix-shell\n```\n\n# Making Nix Shells\n\n## Aliases\n\nNix's `shellHook` can provide aliases, but since `devShells` are made in `bash`,\nwriting aliases in `shellHook` does not work for shells like `zsh`.\n\nThis is especially a problem if one uses [direnv](https://direnv.net) (e.g. with\n[nix-direnv](https://github.com/nix-community/nix-direnv)), which automatically\ndrops you into your current shell.\n\nHowever, there is a workaround: `pkgs.writeShellScriptBin`. This is a trivial builder\nthat writes a script file to `/nix/store/\u003cstore path\u003e/bin/\u003cfile\u003e`, and if included in\nthe shell's packages list, can be made available and executable for the user.\n\nThis repo stores these scripts in a set whose leaves can be included separately\nin the shell's packages list.\n\n**Example:**\n\n`shell.nix`\n\n```nix\n{ pkgs ? import \u003cnixpkgs\u003e { } }:\nlet\n  aliases = {\n    uwu-hello = pkgs.writeShellScriptBin \"uwu-hello\"\n      ''\n        hello -g \"hewwo?\"\n      '';\n\n    custom-hello = pkgs.writeShellScriptBin \"uwu-hello\"\n      ''\n        hello -g \"$@\"\n      '';\n  };\nin\npkgs.mkShell {\n  packages = with pkgs; [\n    hello\n    aliases.custom-hello\n  ];\n}\n```\n\nIn the shell, `custom-hello \"hi\"` does `hello -g \"hi\"`, but `uwu-hello` is not a command.\n\n## Configuration files\n\n`shellHook` can symlink existing files to the specified location. For simplicity's\nsake, that is what I do in this repo.\n\nAlternatively, you can write something like this:\n\n`shell.nix`\n\n```nix\n{ pkgs ? import \u003cnixpkgs\u003e { } }:\n\npkgs.mkShell {\n  # ...\n\n  shellHook =\n    let\n      config_file = builtins.toFile \"config.toml\"\n        ''\n          foo = \"bar\"\n\n          [baz]\n          hello = 1\n        '';\n    in\n    ''\n      ln -s ${config_file} ~/.config/example/config.toml\n    '';\n}\n```\n\nOr use the variations of `pkgs.writeTextFile`, `pkgs.writeText`, etc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmimvoid%2Fnix-shells","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmimvoid%2Fnix-shells","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmimvoid%2Fnix-shells/lists"}