Skip to content

Conversation

@JumpIn-Git
Copy link

When blueprint imports lib/default.nix, it only passes inputs and flake. Nixpkgs lib will probaly be used in the function so we can pass it, since inputs.nixpkgs.lib doesn't depend on system and the nixpkgs input will always be available because the inputs of blueprint and the guest are combined.

When blueprint imports `lib/default.nix`, it only passes inputs and
flake. Nixpkgs lib will probaly be used in the function so we can pass
it, since `inputs.nixpkgs.lib` doesn't depend on system and the
`nixpkgs` input will always be available because the inputs of blueprint
and the guest are combined.
@phaer
Copy link
Member

phaer commented Mar 25, 2025

Is this is effectively just an alias, or would this enable you to do anything you can't (easily) do now?

If the intention to allow users to reference lib instead inputs.nixpkgs.lib? If so, my first impulse is to let users do that in a let statement or so to keep the meaning of lib explicit in each file - as it's somewhat common to extend it in various ways.

The overly generic name lib might be a mistake, but it's a mistake made outside (and long before) blueprint.

Some loosely related discussion in #16

@JumpIn-Git
Copy link
Author

JumpIn-Git commented Mar 25, 2025

Is this is effectively just an alias, or would this enable you to do anything you can't (easily) do now?

If the intention to allow users to reference lib instead inputs.nixpkgs.lib? If so, my first impulse is to let users do that in a let statement or so to keep the meaning of lib explicit in each file - as it's somewhat common to extend it in various ways.

The overly generic name lib might be a mistake, but it's a mistake made outside (and long before) blueprint.

Some loosely related discussion in #16

this pr only passes inputs.nixpkgs.lib to lib/default.nix, atm you need to bootstrap like this:

lib/default.nix
{inputs}: let
  inherit (inputs.nixpkgs) lib;
in

since lib will probably be used to make functions, it should be passed to lib/default.nix by default

@phaer
Copy link
Member

phaer commented Mar 25, 2025

That's what I meant by "alias". You say "probably" and that might be, but there are various other - somewhat conventional ways to use it, where this PR doesn't safe much. i.e.

{inputs}: let
  inherit (inputs.nixpkgs.lib) mapAttrs attrsToList;
in

or

{inputs}: let
  lib = inputs.nixpkgs.lib.extend (inputs.my-fancy-lib);
in

Additionally, your example is less implicit, than just a {inputs, lib}:. With inputs.nixpkgs.lib its even clearer where lib came from and to alias it as in your example is a single line of very easy code, so I am not yet convinced this PR presents a good trade-off.

@JumpIn-Git
Copy link
Author

yeah i see your point, this only saves 1/2 lines.

@JumpIn-Git JumpIn-Git closed this Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants