Handy scripts for fuzzy searching nixpkgs and nixos-options

Might as well post my little script here for searching files in a directory that contains all the given words, no matter what line they’re on. So it’s awesome for writing your own package and searching examples in nixpkgs like “where did someone use makeWrapperArgs and PATH”.

#!/usr/bin/env ruby

Dir.glob('**/*') do |path|
  next unless File.file?(path)
  File.open(path, 'r:binary'){|io|
    ARGV.all?{|word|
      io.rewind
      io.grep(/#{word}/).any?
    } && puts(path)
  }
end

Usage like find-all-with-words setupPyBuildFlags buildPython.

2 Likes