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? 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/, which prompted me to download downloaded NixOS-nixpkgs-24.05-pre-77301-g6c0b7a92.tar.gz
. After unpacking that:
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)
Usually I follow the Source link from NixOS Search:
![screenshot](https://discourse.nixos.org/uploads/default/original/3X/5/3/5358dffc212ad960df21a472a989da2e65ceaf8b.png)
I do these often enough that it was worth setting up a search keyword in Firefox:
np → https://search.nixos.org/packages?type=packages&query=%s
3 Likes
Super! Simple and works. I like it.
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 so if you want specifically to search in the *unstable^, you can do:
nix search github:NixOS/nixpkgs/nixos-unstable foo
nixos-unstable
is the name of the branch in the nixpkgs repo.
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
:
$ 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:
$ nix search github:NixOS/nixpkgs/nixos-unstable vim | wc -l
4629
)
One can find the file that contains a particular derivation by accessing the meta.position
attribute:
$ nix eval nixpkgs#vim.meta.position
"/nix/store/zyzhqfys86byv201frlpiyipzzw38p02-source/pkgs/applications/editors/vim/common.nix:36"
2 Likes
https://mynixos.com/ is also good. nixpkgs + options + home-manager things. this was most fast one.
2 Likes
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:
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…
1 Like