numtide / nix-filter

a small self-contained source filtering lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve the doc

zimbatm opened this issue · comments

The doc could be better.

What is the best notation to describe nix functions?

Are all the use-cases covered in the readme?

Before I create a separate issue, I would like to piggy-back on this issue:

Are all the use-cases covered in the readme?

I was about to create another issue because the readme does not state anything about flake/flake support.
As a nix-n00b, I first assumed that it doesn't support flakes and wasn't sure how to include it in my flake-based project.
Only after looking at the project for the second time, I saw that it does include flake.nix.
So I would like to extend the Usage section as:

Flake support

Or alternatively, if you are using it as a flake, this is how you could use it in your flake.nix file:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
    nix-filter.url = "github:numtide/nix-filter";
  };
  outputs = { self, nixpkgs, nix-filter }:
    let
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      # Avoid calling it nix-filter as it may result in an infinite recursion
      filter = import nix-filter;
     # ....
    
    in
    {
      # ...
    };
}

PS: Happy to make this as a real PR

Sounds good!

The flake usage is like this:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
    nix-filter.url = "github:numtide/nix-filter";
  };
  outputs = { self, nixpkgs, nix-filter }:
    let
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      # Avoid calling it nix-filter as it may result in an infinite recursion
      filter = nix-filter.lib;
     # ....
    
    in
    {
      # ...
    };
}