WGUNDERWOOD / tex-fmt

An extremely fast LaTeX formatter written in Rust
MIT License
265 stars 20 forks source link

Add overlay output to `flake.nix` via `overlay.nix` #25

Closed wholikeel closed 2 months ago

wholikeel commented 2 months ago

Adds an overlay.nix that is provided as an output from flake.nix.

Allows using an up-to-date version of tex-fmt in end user's Nix flakes without depending on nixpkgs-unstable.

Using overlays creates a much cleaner flake.nix compared to using the package output directly.

Example:

{
  description = "...";
  inputs = {
    nixpkgs.url     = "github:NixOS/nixpkgs/24.05";
    tex-fmt.url     = "github:WGUNDERWOOD/tex-fmt";
    flake-utils.url = "github:numtide/flake-utils";
  };
  outputs = {nixpkgs, flake-utils, tex-fmt, ...}:
    flake-utils.lib.eachDefaultSystem (system: 
    let
      pkgs = nixpkgs.legacyPackages.${system}.extend (
        tex-fmt.overlays.default
      );
    in {
      devShells = {
        default = pkgs.mkShell {
          name = "...";
          packages = with pkgs; [
            texlab
            tex-fmt
            ...
          ];
        };
      };
      ...
    });
}
WGUNDERWOOD commented 2 months ago

Thanks so much for this! A few comments (I'm not very familiar with Nix overlays):

wholikeel commented 2 months ago

No worries!

* In `overlay.nix` you have `_: prev: {...}` - is there a reason this doesn't follow the `final: prev: {...}` syntax?

final wouldn't be bound in the proceeding expression, so I believe its convention to name unused function parameters as _.

* Please format the `.nix` files using [Alejandra](https://github.com/kamadorueda/alejandra%60)
* Please squash these commits to a single commit

:+1:

WGUNDERWOOD commented 2 months ago

Thanks for the explanation and for formatting/squashing!