I’ve been trying to get packageOverrides to work for selectively pinning packages to unstable, but it only seems to work when using the with pkgs syntax there and when installing packages. It is my understanding that the use of with is discouraged, but I’m not sure how to avoid it here.
For attempting packageOverrides without with, I’m completely at a loss. I’ve dug into the language documentation trying to figure out what exactly is going on there, and how it can work without with fruitlessly. All I’ve been able to learn is that the attrValuesinherit trick is nonsensical to attempt here.
On a side note, is there a cleaner way to do the package setup, or will it necessarily need two inherit statements since inherit (pkgs) unstable.junicode; doesn’t work?
Something else is wrong, your code should work. That said, I don’t recommend using an overlay for this, it just doesn’t make sense; you’re abusing pkgs as a global variable, we don’t need to do that.
We can use the module args - which are actually intended to serve as global module args - to do so instead:
Then you can use it in the module args like you can pkgs.
To talk about your actual issue, it would have been nice to know the actual error, though the immediate problem I see in the commented out version, is that its override function returns a list, rather than a set.
Yes, I do ultimately wand to be able to override what packages are being used on imported files as well. Unfortunately, the suggested methods don’t seem to work.
TLATER error
...
let
pkgs-unstable = import <nixos-unstable> {
inherit (config.nixpkgs) config;
};
in {
_module.args = { inherit pkgs-unstable };
...
I got the following error
building the system configuration...
error:
… while evaluating the attribute 'config'
at /nix/store/mzf1mpn0h1jq6mxypihkb2s5s1i8psxm-source/lib/modules.nix:361:9:
360| options = checked options;
361| config = checked (removeAttrs config [ "_module" ]);
| ^
362| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/mzf1mpn0h1jq6mxypihkb2s5s1i8psxm-source/lib/modules.nix:361:18:
360| options = checked options;
361| config = checked (removeAttrs config [ "_module" ]);
| ^
362| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: syntax error, unexpected '}'
at /etc/nixos/configuration.nix:14:41:
13| in {
14| _module.args = { inherit pkgs-unstable };
| ^
15| # switch NIX_PATH to use npins
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel --dry-run' returned non-zero exit status 1.
For @NobbZ variant you’ve not added the module to the args, though I deliberately didn’t because I forget if this edge case leads to infinite recursion.
It doesn’t, unless I’ve misunderstood the question you’re asking. Setting _module.args directly and then binding from the arg is a little cleaner than using a let, imo.
… which I agree is clearer, I just didn’t want to accidentally share untested code that’s going to give an obtuse error. Looks like a syntax mistake was bad enough
Thank you both very much. Both approaches with those corrections. looking back and forth on the error messages and how to fix them, they make a bit more sense.
Seeing as the overlays method is the wrong tool for the job here anyways, I don’t mind leaving that question unsolved.