| 20 Apr 2025 |
Tristan Ross | I can think unmaintained and vulnerable are the two most common | 15:40:08 |
Tristan Ross | If we make it a list then we could have: reasons = [ unmaintained vulnerable ] | 15:40:35 |
Tristan Ross | It could throw an error that looks something like this:
Package "xyz" was removed since xx.xx due to the following reasons:
- Unmaintained: package has not been updated or maintained for an extended period of time
- Vulnerable: package contains security vulnerability and should not be trusted
| 15:42:25 |
Tristan Ross | It's a pretty clear error | 15:42:46 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | Well the real question I'd like to ask is how do we tell users the pkgs variant cannot be used is because they didn't enable config.allowVariants | 15:44:53 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | Other wise it feels like "I sometimes can use them, sometimes it just isn't there but I don't know what is exactly going wrong" | 15:45:36 |
Tristan Ross | For now, I made it to where you have to explicitly disable it. | 15:46:32 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | In reply to @rosscomputerguy:matrix.org For now, I made it to where you have to explicitly disable it. Yeah, but if people trigger ofborg errors, they should get an explanation in place | 15:47:14 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | The aliases are already confusing but we can make them correct | 15:47:41 |
Tristan Ross | So what we can do is "fake-import" it | 15:48:03 |
Tristan Ross | I tested in repl and got this:
nix-repl> builtins.attrNames (import ./pkgs/top-level/variants.nix { nixpkgsFun = import ./.; lib = pkgs.lib; stdenv = pkgs.stdenv; overlays = pkgs.overlays; makeMuslParsedPlatform = null; } pkgs pkgs)
[
"pkgsArocc"
"pkgsExtraHardening"
"pkgsLLVM"
"pkgsLLVMLibc"
"pkgsMusl"
"pkgsRocm"
"pkgsZig"
]
| 15:48:46 |
Tristan Ross | With this, we can map the names and throw an error saying that config.allowVariants need to be enabled. | 15:49:18 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | Can we use some = allow: builtins.mapAttrs (k: v: if allow then v else throw "not allowed") { a = 1; } | 15:52:04 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | Will it fail too eagerly for this | 15:52:24 |
Tristan Ross | Yes, I'm working on that logic right now. | 15:52:27 |
Tristan Ross | mkOptionalOverlay =
{
configOption,
type,
overlay,
}:
self: super:
let
pkgs = overlay self super;
in
if config."${configOption}" then
pkgs
else
lib.mapAttrs (
name: _: throw "${name} ${type} is not available, please enable config.${configOption}"
) pkgs;
| 15:55:32 |
Tristan Ross | nix-repl> pkgs.pkgsLLVM
error:
… while calling the 'throw' builtin
at /home/ross/nixpkgs/pkgs/top-level/stage.nix:206:18:
205| lib.mapAttrs (
206| name: _: throw "${name} ${type} is not available, please enable config.${configOption}"
| ^
207| ) pkgs;
error: pkgsLLVM nixpkgs variant is not available, please enable config.allowVariants
| 15:55:53 |
Tristan Ross | Aye, it integrates well with aliases. | 15:58:21 |
Tristan Ross | nix-repl> pkgs.zig_0_9
error:
… while calling the 'throw' builtin
at /home/ross/nixpkgs/pkgs/top-level/stage.nix:206:18:
205| lib.mapAttrs (
206| name: _: throw "${name} ${type} is not available, please enable config.${configOption}"
| ^
207| ) pkgs;
error: zig_0_9 package is not available, please enable config.allowAliases
| 15:58:39 |
Tristan Ross | This was a good idea | 15:59:14 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | In reply to @rosscomputerguy:matrix.org
mkOptionalOverlay =
{
configOption,
type,
overlay,
}:
self: super:
let
pkgs = overlay self super;
in
if config."${configOption}" then
pkgs
else
lib.mapAttrs (
name: _: throw "${name} ${type} is not available, please enable config.${configOption}"
) pkgs;
Wow, just an overlay | 16:15:42 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | Didn't think of this | 16:15:48 |
Tristan Ross | Yep and it works perfectly | 16:16:14 |
aleksana 🏳️⚧️ (force me to bed after 18:00 UTC) | In reply to @rosscomputerguy:matrix.org
nix-repl> pkgs.zig_0_9
error:
… while calling the 'throw' builtin
at /home/ross/nixpkgs/pkgs/top-level/stage.nix:206:18:
205| lib.mapAttrs (
206| name: _: throw "${name} ${type} is not available, please enable config.${configOption}"
| ^
207| ) pkgs;
error: zig_0_9 package is not available, please enable config.allowAliases
Does this override already existed throws? | 16:17:09 |
Tristan Ross | Yep | 16:17:18 |
Tristan Ross | zig_0_9 is actually a throw | 16:17:28 |
Tristan Ross | llvmPackages_latest isn't and it works | 16:17:42 |
Tristan Ross | You only get a throw when you consume the value | 16:17:51 |
Tristan Ross | But since we dump the value, we don't consume it | 16:18:06 |
Tristan Ross | * But since we drop the value, we don't consume it | 16:18:13 |