I am new to NixOs and really like the concepts that go into it.
So yesterday I read up on the whole Nix Languaged and feel confident to do some advanced stuff now, conviently there is this one package (redshift) which does not support wayland on 19.09 stable (on 20.03 there is a variation that does) my idea was to use pkgs.redshift.overrideAttrs to override the src attribute with a call to fetchFromGithub but with a set which points to the wayland fork of the project.
Now to the core of the question? How do I make use of fetchFromGithub here, do I have to import it or something?
And the alternative would be to fetch the fork manually and set the src attribute to the path of the local repo, right?
So yesterday I read up on the whole Nix Languaged and feel confident to do some advanced stuff now, conviently there is this one package (redshift) which does not support wayland on 19.09 stable (on 20.03 there is a variation that does) my idea was to use pkgs.redshift.overrideAttrs to override the src attribute with a call to fetchFromGithub but with a set which points to the wayland fork of the project.
Now to the core of the question? How do I make use of fetchFromGithub here, do I have to import it or something?
It depends on how and where you are overriding the attributes of redshift. If you are using an overlay for that you can just access fetchFromGithub by using super.fetchFromGithub.
If you are just overriding in place (e.g. as part of your environment.systemPackages you can probably just use pkgs.fetchFromGithub for that.
And the alternative would be to fetch the fork manually and set the src attribute to the path of the local repo, right?
That would also work but always requires you to keep that checkout
around. I’d prefer using a different src as described above.
Alas, it’s fetchFromGitHub, not fetchFromGithub. I just tried your overlay on my NixOS system and it appears to be working otherwise.
It’d be really nice if we had “did you mean similar variable X” compiler suggestions on the error msg, but another way to check is with nix repl, which has tab completion:
No problem. As another tip, you may want to consider overriding version as well (and possibly pname if it’s a fork and not just a newer version). This is just cosmetic, but it makes it easier to tell that it worked and separate your updated redshift package from the default one.
everything in lib doesn’t result in a derivation, generally these are helper functions, metadata, and other generically useful utilities. Functions and helpers which exist in pkgs generally operate on derivations. (E.g. buildPythonPackage)
Functions that don’t depend on pkgs generally go in lib, which can be imported independently with import <nixpkgs/lib>. Note that it needs no arguments: it does not depend on system, config, overlays, etc.
So as a rule of thumb:
Function creates or uses derivations → pkgs.*
Function does not use derivations → lib.*