Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix repl repl-flake behaves differently than :lf #8059

Open
sg-qwt opened this issue Mar 17, 2023 · 7 comments
Open

nix repl repl-flake behaves differently than :lf #8059

sg-qwt opened this issue Mar 17, 2023 · 7 comments
Labels
bug flakes repl The Read Eval Print Loop, "nix repl" command and debugger

Comments

@sg-qwt
Copy link

sg-qwt commented Mar 17, 2023

Not sure of this is a bug or desired behavior of the new experimental repl-flake.

With repl-flake enabled and entered my nixos flake, when I run nix repl .#, only 5 variables added. In my previous workflow with :lf inside repl, I can see more variables added. Things like input etc are missing by nix repl .#

> nix repl .#
Welcome to Nix 2.13.3. Type :? for help.

Loading installable 'git+file:///home/me/nixos#'...
Added 5 variables.
nix-repl> :lf .#
Added 17 variables
@asymmetric
Copy link
Contributor

Slightly related: is there a way to print defined variables?

@mvnetbiz
Copy link

what's added by nix repl .#

diff nothing.txt replflake.txt | grep \>
> devShells
> legacyPackages
> nixosConfigurations
> overlays
> packages

what's additionally loaded by :lf

diff replflake.txt lf.txt | grep \>
> _type
> inputs
> lastModified
> lastModifiedDate
> narHash
> outPath
> outputs
> sourceInfo
> submodules

The nix <flake>#<attribute> argument apparently only supports the output attributes, so maybe it would make sense to make all nix commands support these attributes too, not just the output attributes. For example, then you could run
nix build .#inputs.nixpkgs.hello to build hello from the nixpkgs input of the flake.

@mvnetbiz
Copy link

This workaround loads all the same attributes as :lf with nix repl .#, but some commands show the "unknown" attributes

{
  outputs = { self, ... }: {
    inherit (self) _type inputs lastModified lastModifiedDate narHash outPath outputs sourceInfo submodules;
  };
}

@Ericson2314 Ericson2314 added flakes repl The Read Eval Print Loop, "nix repl" command and debugger labels Mar 26, 2023
@thufschmitt
Copy link
Member

Discussed during the Nix maintainers meeting on 2024-02-26.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-02-28-nix-team-meeting-129/40499/1

@KiaraGrouwstra
Copy link

@asymmetric:

Slightly related: is there a way to print defined variables?

you can use functions like trace (from builtins/lib).

@mvnetbiz:

what's additionally loaded by :lf

actually, lib differs between the two as well - for :lf it seems to also have stuff like lib.nixosSystem

@thufschmitt
Copy link
Member

actually, lib differs between the two as well - for :lf it seems to also have stuff like lib.nixosSystem

Do you mean that nix repl nixpkgs doesn't give you lib.nixosSystem?

$ nix repl nixpkgs
Nix 2.21.0pre20240304_4388559
Type :? for help.
Loading installable 'flake:nixpkgs#'...
Added 5 variables.
nix-repl> lib.nixosSystem 
«lambda nixosSystem @ /nix/store/3i3rncs75fid9hwai5p2nvwc4ngdnia7-source/flake.nix:21:23»

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug flakes repl The Read Eval Print Loop, "nix repl" command and debugger
Projects
None yet
Development

No branches or pull requests

7 participants