Last active
October 13, 2024 16:17
-
-
Save LnL7/570349866bb69467d0caf5cb175faa74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self: super: | |
{ | |
# Install overlay: | |
# $ mkdir -p ~/.config/nixpkgs/overlays | |
# $ curl https://gist.githubusercontent.com/LnL7/570349866bb69467d0caf5cb175faa74/raw/3f3d53fe8e8713ee321ee894ecf76edbcb0b3711/lnl-overlay.nix -o ~/.config/nixpkgs/overlays/lnl.nix | |
userPackages = super.userPackages or {} // { | |
# Example: | |
hello = self.hello; | |
# add more packages here... | |
# Default packages: | |
# cacert = self.cacert; | |
# nix = self.nix; # don't enable this on multi-user. | |
nix-rebuild = super.writeScriptBin "nix-rebuild" '' | |
#!${super.stdenv.shell} | |
if ! command -v nix-env &>/dev/null; then | |
echo "warning: nix-env was not found in PATH, add nix to userPackages" >&2 | |
PATH=${self.nix}/bin:$PATH | |
fi | |
exec nix-env -f '<nixpkgs>' -r -iA userPackages "$@" | |
''; | |
}; | |
} |
@Amir-Ahmad Oh I think you probably put this in ~/.config/nixpkgs/overlays/
directly, yes? I suppose I should have elaborated. Your directory structure should look like
~/.config/nixpkgs/overlays/
userPackages/
default.nix
packages.nix
The nested folder name (userPackages
above) doesn't matter, but the two files do need to be nested in a folder, and the main file is default.nix
in this folder.
What this does is it makes userPackages/default.nix
to be the actual overlay, and that in turn imports ./packages.nix
to construct the userPackages
set. By putting both files in the top level overlays folder you instead make them two separate overlays and the packages.nix
file is then trying to overwrite each package with itself, which causes infinite recursion.
@lilyball It's working now! thanks for the explanation 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lilyball I was trying with this, copied from your comment https://gist.github.com/LnL7/570349866bb69467d0caf5cb175faa74#gistcomment-3372828.