Skip to content

jfly/flake-input-patcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flake-input-patcher

Tired of waiting for PRs to land? Stop waiting!

Utility to patch nix flake inputs.

This can go away when nix supports patching flake inputs: NixOS/nix#3920.

Usage

Usage in a flake.nix:

{
  inputs = {
    flake-input-patcher.url = "github:jfly/flake-input-patcher";

    # Feel free to use `follows`. If it points at a patched input, the right
    # thing will happen!
    systems.follows = "dep1/systems";

    # ... More inputs here ...
  };

  outputs =
    unpatchedInputs:
    let
      # Unfortunately, this utility requires hardcoding a single system. See
      # "Known issues" below.
      patcher = unpatchedInputs.flake-input-patcher.lib.x86_64-linux;

      inputs = patcher.patch {
        inherit unpatchedInputs;
        flakePath = ./.;
        patchSpec = {
          # Patching a direct dependency:
          nixpkgs.patches = [
            (patcher.fetchpatch {
              name = "k3s: use patched util-linuxMinimal";
              url = "https://github.com/NixOS/nixpkgs/pull/407810.diff";
              hash = "sha256-N8tzwSZB9d4Htvimy00+Jcw8TKRCeV8PJWp80x+VtSk=";
            })
          ];

          # Patching a transitive dependency:
          clan-core.inputs.data-mesher.patches = [
             # ... More patches here ...
          ];
        };
      };
    in
    # Define your flake as normal using `inputs`!
}

Known issues

  • nix does not (yet) have a patch builtin, so we use system-specific utilities in nixpkgs (fetchpatch and applyPatches), which means you have to hardcode a system to make it work.
  • This depends on Input From Derivation (IFD).
  • Support for input following depends on parsing your flake's flake.lock file. I'm not sure how brittle this approach is. See branch follows-without-lockfile-abandoned for an alternate approach that does not depend on the lockfile. I abandoned this approach before I got it completely working, but I think it is a viable approach, it just is much more work than leveraging the lockfile (which implicitly captures information about how inputs directives are resolved across multiple flakes).

Alternatives

In the wild

Feel free to add a link to your repo here!

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages