From 68103079f485b5197066abd4f5e1e5d9a9c09160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Fri, 4 Oct 2024 16:52:42 +0200 Subject: [PATCH] nix: example of local package overrides during development (#2607) --- flake.lock | 6 +++--- flake.nix | 1 + nix/overlay.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 nix/overlay.nix diff --git a/flake.lock b/flake.lock index 30b11d5b..04d386b3 100644 --- a/flake.lock +++ b/flake.lock @@ -978,11 +978,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1727859277, - "narHash": "sha256-AsrPuQqhg8x5RRR3aX0vvDDRQb+HREq2wGxXOpZnWus=", + "lastModified": 1728029332, + "narHash": "sha256-j0RX3a67lvi2PC5w6J5DHTxM+l96J/OV5sAf34IUfUo=", "owner": "huggingface", "repo": "text-generation-inference-nix", - "rev": "14196ab62f31d005f46207f7a251f82a81d0a09f", + "rev": "98049f853346ca780b81fee730715c90d33ac2b4", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 22fa8cfc..edef442f 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ overlays = [ rust-overlay.overlays.default tgi-nix.overlays.default + (import nix/overlay.nix) ]; }; crateOverrides = import ./nix/crate-overrides.nix { inherit pkgs nix-filter; }; diff --git a/nix/overlay.nix b/nix/overlay.nix new file mode 100644 index 00000000..f7b9b8c2 --- /dev/null +++ b/nix/overlay.nix @@ -0,0 +1,41 @@ +final: prev: { + # You can use this overlay to temporarily override packages for + # development. For permanent overrides, it's better to do this in + # our package flake: + # + # https://github.com/huggingface/text-generation-inference-nix + # + # Note that overriding packages that are in the transitive closure + # of many other packages (e.g. transformers) will require a large + # rebuild. + + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + ( + python-self: python-super: with python-self; { + # Python package override example: + # transformers = python-super.transformers.overrideAttrs ( + # _: _: { + # src = final.fetchFromGitHub { + # owner = "huggingface"; + # repo = "transformers"; + # rev = "2bd4d5897dc73e8b172832070a6f9e567a0df017"; + # hash = "sha256-JOIpKH9ssDEfI2Tf15e0iPKtThJwQ9GxMvRAnm+M2Pg="; + # }; + # } + # ); + } + ) + ]; + + # Non-python package override example: + # + # ripgrep = prev.ripgrep.overrideAttrs ( + # _: _: { + # src = final.fetchFromGitHub { + # owner = "BurntSushi"; + # repo = "ripgrep"; + # rev = "79cbe89deb1151e703f4d91b19af9cdcc128b765"; + # hash = "sha256-JPTM2KNmGMb+/jOfK3X7OM1wnN+3TU35SJOIcqmp3mg="; + # }; + # }); +}