Hi, I am pretty new to NixOS and I am trying to create a git which contains a bunch of custom overlays which I have written to use as a development environment for another project. I have got this working using a default.nix and importing it into my shell on the project but I would like to update this to a flake. I am really struggling with groking flakes.
Unless you’re replacing existing dependencies of existing packages, you don’t really an overlay for this, and they do come with a somewhat heavy computational cost. Right now you’re just using the overlay to put values in pkgs and immediately extracting them again. There’s no actual need for pkgs to be involved in transporting them around.
That said, the most straightforward conversion of what you have is to make one flake which has the overlay as an output, then use that flake as an input to another flake with a devShell output. You reference the overlay through the flake input instead of using a fetchtarball.
Thanks very much everyone this is very helpful. I downloaded the nix-start-configs and have been experimenting with it but I am experiencing a issue with package dependency.
For example:
I have a application and library that are not in nixpkgs and application depends on the library - how would I ensure that the application has access to the library? Right now I get the following error
error: Function called without required argument "lib1" at /nix/store/s94wkwdpqpaj6w4mvbghbbxp1558sjxm-source/pkgs/app1/default.nix:12
This previously worked when using self:super, here is what the application nix looks like:
Well here where is your overlay supposed to come from? From an external flake? Then you need to add your flake as an input as explained by @tejing. Also, your pkgs needs to say that it uses the overlay, so instead of pkgs = nixpkgs.legacyPackages.${system}; you should do somethink like:
let pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
self.overlays.default # For an overlay defined in the current flake
a.overlays.default # For an overlay defined in a dependency "a" of your flake as explained by tejing
];
}; in …
edit oh I see, I read too quickly your message. Let me correct my message
Ah I think I see what disturb you, I read too quickly your message. All your libraries are in the current flake so you don’t need to add an external flake. What you want to do is to create a local overlay with your libraries, add this overlay to pkgs, and just add the wanted packages to packages.
callPackage automatically fills in things that are in nixpkgs, but for anything else, or anything you want to override for some reason, you need to include it in the argument to callPackage.