-
-
Save LnL7/570349866bb69467d0caf5cb175faa74 to your computer and use it in GitHub Desktop.
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 "$@" | |
''; | |
}; | |
} |
@lilyball thanks for the quick reply, my packages.nix
:
self: super:
# Packages exposed as part of nixpkgs.userPackages
{
inherit (self)
aspell
bc
coreutils
gdb
# ...
# gnome3.dconf-editor
# xorg.xdpyinfo
# xorg.xev
# ...
;
}
If I don't comment out the above lines with the .
, I get the mentioned error, but if I don't use the full attribute path (i.e. when I just have e.g. xev
in the file), the package is not found:
$ nix-rebuild
at: (3:2) in file: /home/ppenguin/.config/nixpkgs/packages.nix
2| # Packages exposed as part of nixpkgs.userPackages
3| {
| ^
4| inherit (self)
attribute 'xev' missing
$ nix-env -qaP '.*xev.*' | cat
nixos.xorg.xev xev-1.2.3
If I quote like this "xorg.xev"
or like this "nixos.xorg.xev"
, it also gives me the attribute missing
error.
I'm using the latest script you posted.
@ppenguin You can’t use dotted paths in inherit
like that. You’ll have to write it like
{
inherit (self)
aspell
bc
coreutils
gdb
;
inherit (self.gnome3)
dconf-editor
;
inherit (self.xorg)
xdpyinfo
xev
;
}
@lilyball Thanks a lot, that's something I'd have figured out by myself about a few decades later 😁
does this need to be setup for every channel?
@lilyball thanks for sharing that, looks great. I'm getting an infinite recursion error when trying to use your 2020 version (The older one works fine).
nix-env -f '' -r -iA userPackages
error: infinite recursion encountered, at /home/user/.config/nixpkgs/overlays/packages.nix:4:17
Any idea what could be causing this?
@Amir-Ahmad What does your packages.nix
look like?
@lilyball I was trying with this, copied from your comment https://gist.github.com/LnL7/570349866bb69467d0caf5cb175faa74#gistcomment-3372828.
self: super:
# Packages exposed as part of nixpkgs.userPackages
{
inherit (self)
fish tmux
# …
;
}
@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 👍
@ppenguin You’ll have to show your
packages.nix
(or at least line 13), because the period there isn’t in the package name, it’s just part of the attribute path.If the period was part of the package name (like in my case I have a package named
apollo-2.30.2
) you have to quote the name, likenixpkgs."apollo-2.30.2"
), but that’s not the case here. What you have here is just a syntax error and I can’t diagnose it without seeing the code.