git.iko.soy/typeable/nixpkgs
on master help sign in
Update python.md (#23669)
91debcbJoachim Schiele
doc/languages-frameworks/python.md+21
@@ -897,6 +897,27 @@ is executed it will attempt to download the python modules listed in
897requirements.txt. However these will be cached locally within the `virtualenv`
897requirements.txt. However these will be cached locally within the `virtualenv`
898folder and not downloaded again.
898folder and not downloaded again.
899
899
900+### How to override a Python package from `configuration.nix`?
901+
902+If you need to change a package's attribute(s) from `configuration.nix` you could do:
903+
904+```nix
905+ nixpkgs.config.packageOverrides = superP: {
906+ pythonPackages = superP.pythonPackages.override {
907+ overrides = self: super: {
908+ bepasty-server = super.bepasty-server.overrideAttrs ( oldAttrs: {
909+ src = pkgs.fetchgit {
910+ url = "https://github.com/bepasty/bepasty-server";
911+ sha256 = "9ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
912+ rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
913+ };
914+ });
915+ };
916+ };
917+ };
918+```
919+
920+If you are using the `bepasty-server` package somewhere, for example in `systemPackages` or indirectly from `services.bepasty`, then a `nixos-rebuild switch` will rebuild the system but with the `bepasty-server` package using a different `src` attribute. This way one can modify `python` based software/libraries easily. Using `self` and `super` one can also alter dependencies (`buildInputs`) between the old state (`self`) and new state (`super`).
900
921
901## Contributing
922## Contributing
902
923