What is the convention for creating a tarball that works both as a package set and an overlay. Is it to create two tarballs, one for the package set and one for the overlay or is it some way to combine them. Both are using the default.nix and when provided as a tarball URL, you can’t specify the entry point.
I currently have something like this:
{ overlaySupport ? false
, pkgs ? import <nixpkgs> {}
}:
let
overlay = import ./pkgs/all-packages.nix;
allPackages = overlay allPackages pkgs;
in if overlaySupport
then overlay
else allPackages
Which would allow something like this:
let
customOverlay = import (builtins.fetchTarball {
url = "file:///custompkgs.tar.gz";
sha256 = "...";
}) { overlaySupport = true; };
in import <nixpkgs> {
overlays = [ customOverlay ];
}
And I also considered to do something like this:
{ pkgs ? import <nixpkgs> {} }:
let
overlay = import ./pkgs/all-packages.nix;
allPackages = overlay allPackages pkgs;
in allPackages // { inherit overlay; }
Which would allow:
let
customOverlay = (import (builtins.fetchTarball {
url = "file:///custompkgs.tar.gz";
sha256 = "...";
}) { }).overlay
in import <nixpkgs> {
overlays = [ customOverlay ];
}
But would these two even be considered overlay compatible. Could they work via nixpkgs-overlays in NIX_PATH? I guess not.
Requirements:
I want to be able to use the tarball as an overlay, via e.g. builtins.fetchTarball
.
I want to be able to install individual packages via the tarball, such as:
nix-env -f file:///custompkgs.tar.gz -iA custompackage
I want to be able to add the package set as a channel:
nix-channel --add file:///custompkgs.tar.gz custompkgs
Preferably when using as an overlay it should just be:
let
customOverlay = import (builtins.fetchTarball {
url = "file:///custompkgs.tar.gz";
sha256 = "...";
});
in import <nixpkgs> {
overlays = [ customOverlay ];
}
Is there a way to satisfy both with a single default.nix? Or should I package the overlay and package set separately.