# How do I find a package in https://github.com/NixOS/nixpkgs?

**URL:** https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735
**Category:** Help
**Created:** [May 20, 2024, 6:32pm UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735 "2024-05-20T18:32:39Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pmorch](https://discourse.nixos.org/user_avatar/discourse.nixos.org/pmorch/32/16533_2.png) [@pmorch](https://discourse.nixos.org/u/pmorch)
#### Post date: [May 20, 2024, 6:32pm UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/1 "2024-05-20T18:32:39Z")

</div>

Hi,

In the last couple of days, I wanted to look at the source for both `vim` and for `awscli2` in unstable. But how do I find them in the massive tree that is [nixpkgs/pkgs at nixos-unstable · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/tree/nixos-unstable/pkgs)? Searching in github for e.g. `vim` does not yield useful results for me.

To do that, I went to [https://github.com/NixOS/nixpkgs/tarball/nixos-unstable/](https://github.com/NixOS/nixpkgs/tarball/nixos-unstable/), which prompted me to download downloaded `NixOS-nixpkgs-24.05-pre-77301-g6c0b7a92.tar.gz`. After unpacking that:

```plaintext
me@machine:~/Downloads/NixOS-nixpkgs-6c0b7a9/pkgs» find . -name vim -o -name awscli2
./applications/editors/vim
./test/vim
./tools/admin/awscli2

```

The human in me knows to use `./applications/editors/vim` and disregard `./test/vim`.

But what is the canonical way to find the source directory for a given random package? (Which I assume could be different in e.g. 23.11 and unstable)

---

<div class="post-metadata">

### Author: ![\_Andrew](https://discourse.nixos.org/user_avatar/discourse.nixos.org/_andrew/32/10331_2.png) [@\_Andrew](https://discourse.nixos.org/u/_Andrew)
#### Post date: [May 20, 2024, 8:15pm UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/2 "2024-05-20T20:15:48Z")

</div>

Usually I follow the Source link [from NixOS Search](https://search.nixos.org/packages?type=packages&query=vim):

> [![screenshot](https://discourse.nixos.org/uploads/default/original/3X/5/3/5358dffc212ad960df21a472a989da2e65ceaf8b.png)](https://search.nixos.org/packages?type=packages&query=vim)

I do these often enough that it was worth setting up a search keyword in Firefox:

```auto
np → https://search.nixos.org/packages?type=packages&query=%s

```

---

<div class="post-metadata">

### Author: ![pmorch](https://discourse.nixos.org/user_avatar/discourse.nixos.org/pmorch/32/16533_2.png) [@pmorch](https://discourse.nixos.org/u/pmorch)
#### Post date: [May 20, 2024, 9:58pm UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/3 "2024-05-20T21:58:36Z")

</div>

> [@\_Andrew](#):
>
> Usually I follow the Source link [from NixOS Search](https://search.nixos.org/packages?type=packages&query=vim)

Super! Simple and works. I like it.

---

<div class="post-metadata">

### Author: ![azazel75](https://discourse.nixos.org/user_avatar/discourse.nixos.org/azazel75/32/177_2.png) [@azazel75](https://discourse.nixos.org/u/azazel75)
#### Post date: [May 21, 2024, 12:22am UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/4 "2024-05-21T00:22:58Z")

</div>

you can also use `nix search nixpkgs foo`, where `nixpkgs` in this case is an alias from the registry, but can be any kind of [flake reference](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake#examples) so if you want specifically to search in the \*unstable^, you can do:

```auto
nix search github:NixOS/nixpkgs/nixos-unstable foo

```

`nixos-unstable` is the name of the branch in the nixpkgs repo.

---

<div class="post-metadata">

### Author: ![pmorch](https://discourse.nixos.org/user_avatar/discourse.nixos.org/pmorch/32/16533_2.png) [@pmorch](https://discourse.nixos.org/u/pmorch)
#### Post date: [May 21, 2024, 8:16am UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/5 "2024-05-21T08:16:44Z")

</div>

Thanks, @azazel75 for your suggestion. A cli suggestion would be even better. I’m not seeing `nix search` providing a link to the source, though. This finds vim, but doesn’t show me `./applications/editors/vim`:

```auto
$ nix search github:NixOS/nixpkgs/nixos-unstable#vim        
* legacyPackages.x86_64-linux.vim (9.1.0377)
  The most popular clone of the VI editor

```

(Your suggestion finds every package that mentions vim which is very noisy:

```auto
$ nix search github:NixOS/nixpkgs/nixos-unstable vim | wc -l
4629

```

)

---

<div class="post-metadata">

### Author: ![kotatsuyaki](https://discourse.nixos.org/user_avatar/discourse.nixos.org/kotatsuyaki/32/17519_2.png) [@kotatsuyaki](https://discourse.nixos.org/u/kotatsuyaki)
#### Post date: [May 21, 2024, 8:58am UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/6 "2024-05-21T08:58:21Z")

</div>

One can find the file that contains a particular derivation by accessing the `meta.position` attribute:

```auto
$ nix eval nixpkgs#vim.meta.position
"/nix/store/zyzhqfys86byv201frlpiyipzzw38p02-source/pkgs/applications/editors/vim/common.nix:36"

```

---

<div class="post-metadata">

### Author: ![dontdieych](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dontdieych/32/292_2.png) [@dontdieych](https://discourse.nixos.org/u/dontdieych)
#### Post date: [May 21, 2024, 10:25am UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/7 "2024-05-21T10:25:52Z")

</div>

[https://mynixos.com/](https://mynixos.com/) is also good. nixpkgs + options + home-manager things. this was most fast one.

---

<div class="post-metadata">

### Author: ![azazel75](https://discourse.nixos.org/user_avatar/discourse.nixos.org/azazel75/32/177_2.png) [@azazel75](https://discourse.nixos.org/u/azazel75)
#### Post date: [May 21, 2024, 10:34am UTC](https://discourse.nixos.org/t/how-do-i-find-a-package-in-https-github-com-nixos-nixpkgs/45735/8 "2024-05-21T10:34:39Z")

</div>

> [@pmorch](#):
>
> ```auto
> $ nix search github:NixOS/nixpkgs/nixos-unstable vim | wc -l
> 4629
> 
> ```

this count has a x3 amount of lines anyway, I admit that’s may be too much. The text to search is really a regexp so you can do searches like:

```auto
nix search github:NixOS/nixpkgs/nixos-unstable '^vim.{0,2}$'
* legacyPackages.x86_64-linux.vim (9.1.0377)
  The most popular clone of the VI editor

* legacyPackages.x86_64-linux.vimb (3.6.0)
  A Vim-like browser

* legacyPackages.x86_64-linux.vimb-unwrapped (3.6.0)
  A Vim-like browser

* legacyPackages.x86_64-linux.vimer (0.2.0)
  A convenience wrapper for gvim/mvim --remote(-tab)-silent to open files in an existing instance of GVim or MacVim. 

* legacyPackages.x86_64-linux.vimpc (0.09.2)
  A vi/vim inspired client for the Music Player Daemon (mpd)

```

although I find the result a bit strange…
