{"id":30071006,"url":"https://github.com/katrinafyi/nix-patcher","last_synced_at":"2026-02-10T06:05:22.506Z","repository":{"id":224537514,"uuid":"763522829","full_name":"katrinafyi/nix-patcher","owner":"katrinafyi","description":"a tool for patching Nix flake inputs, declaratively!","archived":false,"fork":false,"pushed_at":"2024-12-05T02:18:18.000Z","size":26,"stargazers_count":25,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-08T12:22:39.765Z","etag":null,"topics":["flakes","nix"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katrinafyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-26T13:06:48.000Z","updated_at":"2025-06-16T15:20:38.000Z","dependencies_parsed_at":"2024-03-01T03:30:27.996Z","dependency_job_id":"a80c4e05-3af5-41e0-af9f-d220ad6ef327","html_url":"https://github.com/katrinafyi/nix-patcher","commit_stats":null,"previous_names":["katrinafyi/nix-patcher"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/katrinafyi/nix-patcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katrinafyi%2Fnix-patcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katrinafyi%2Fnix-patcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katrinafyi%2Fnix-patcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katrinafyi%2Fnix-patcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katrinafyi","download_url":"https://codeload.github.com/katrinafyi/nix-patcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katrinafyi%2Fnix-patcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29292054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T03:42:42.660Z","status":"ssl_error","status_checked_at":"2026-02-10T03:42:41.897Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flakes","nix"],"created_at":"2025-08-08T12:07:55.978Z","updated_at":"2026-02-10T06:05:22.472Z","avatar_url":"https://github.com/katrinafyi.png","language":"Python","funding_links":[],"categories":["Command-Line Tools"],"sub_categories":[],"readme":"\u003e ⚠️ This tool has not been tested through consistent use, not even by myself.\n\u003e If you're interested in it, though, please give it a try and let me know if it fails.\n\u003e I will work to fix any issues.\n\n\n# nix-patcher\n\n_nix-patcher_ is a tool for patching Nix flake inputs.\nIt semi-automatically maintains a forked nixpkgs with any number of patches applied.\nConfiguration of the upstream repository, fork repository, and patch files are all done\nwithin flake.nix.\n\nFor example, given these inputs (fixed for reproducibility),\n```nix\ninputs.nixpkgs-upstream.url = \"github:nixos/nixpkgs/f9d39fb9aff0efee4a3d5f4a6d7c17701d38a1d8\";\n\ninputs.nixpkgs.url = \"github:katrinafyi/nixpkgs/patch-branch\";  # XXX change me!\n\ninputs.nixpkgs-patch-10.url = \"https://github.com/NixOS/nixpkgs/compare/ffacc011dffba16ca360028d1f81cae99ff1280f..9a9cf8661391f21f7a44dc4823f815524351c94f.patch\";\ninputs.nixpkgs-patch-10.flake = false;\ninputs.nixpkgs-patch-20.url = \"https://github.com/NixOS/nixpkgs/commit/c22a75b70ffe390f4ef3cc3a63eae5fcd5861779.patch\";\ninputs.nixpkgs-patch-20.flake = false;\n```\nnix-patcher will notice the special \"-upstream\" and \"-patch-\" suffixes and match these with \"nixpkgs-upstream\".\nWhen run, the repo and branch to update will be taken from the \"nixpkgs\" inputs.\nThe upstream, patches, and fork inputs are linked together by their common prefix (here, \"nixpkgs\").\n\nBy default, the patched input has no suffix - we assume it will be used most often but this can be configured.\nPatch numbers need not be contiguous as they are only used to determine patch order.\nIt is also permitted to have no patch inputs.\nThe fork repository must be hosted on Github since we make use of Github's API to\nperform the patch without a checkout of nixpkgs.\n\n## usage\n\n### first time\n\nTo set this up, you'll need to add the upstream and patch inputs to your flake.nix.\nAfter this, run `nix flake lock` to generate their lock entries\n(The patched fork and its branch must exist! Create them manually if not.).\nDon't forget to add `...` to your output function's argument list.\n\nFor nix-patcher itself, you will need a Github token.\nA [fine-grained token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)\nis suggested, and it will need at least write permissions on the fork repository.\nIf you plan to use this within Github Actions, you can make use of the\n[automatic token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication).\n\nThen, simply run nix-patcher from within the flake directory\n```bash\nGITHUB_TOKEN=... nix run github:katrinafyi/nix-patcher -- --commit\n```\nIf all goes well, it will update and commit the relevant inputs.\nLinks to the newly-patched branch and the last commit are also printed.\n\nPatching nixpkgs takes around 40 seconds.\n\n### updating inputs\n\nWhen it comes time to update your upstream, the process is much the same.\nFirst, you can run\n```bash\nnix flake update\n```\nThis will upgrade all inputs, including upstreams and the patched forks.\nAssuming nothing has changed our fork's branch in the meantime, this is perfectly safe.\n\nThen, as before,\n```\nGITHUB_TOKEN=... nix run github:katrinafyi/nix-patcher -- --commit\n```\n\nIt is a good idea to perform these two commands as atomically as possible.\nFor example, do not push any changes unless both commands succeed.\nThis will ensure the upstream and forked repositories stay in sync in the lock file.\n\n### arguments\n\n```\nusage: patcher.py [-h] [--flake FLAKE] [--upstream-suffix UPSTREAM_SUFFIX]\n                  [--patched-suffix PATCHED_SUFFIX] [--patch-suffix PATCH_SUFFIX]\n                  [--update] [--commit] [--print] [--tmp TMP]\n\nnix-patcher is a tool for patching Nix flake inputs, semi-automatically.\n\noptions:\n  -h, --help            show this help message and exit\n  --flake FLAKE, -f FLAKE\n                        flake reference\n  --upstream-suffix UPSTREAM_SUFFIX\n                        suffix for upstream repositories (default: -upstream)\n  --patched-suffix PATCHED_SUFFIX\n                        suffix for patched forks (default: '')\n  --patch-suffix PATCH_SUFFIX\n                        suffix for patch files (default: -patch-)\n  --update              if set, will call `nix flake update _` on the newly patched inputs\n  --commit              like --update but also adds --commit-lock-file\n  --print               print detected patches without applying\n  --tmp TMP\n```\n\n## closing\n\nWe made use of the quite clever [patch2pr] tool to perform\nthe patching through Github's API.\nThis enables us to work without any local copies of upstream.\n\n[patch2pr]: https://github.com/bluekeyes/patch2pr\n\nThis project was built with 😠.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatrinafyi%2Fnix-patcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatrinafyi%2Fnix-patcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatrinafyi%2Fnix-patcher/lists"}