Gabriella439 / nixos-in-production

Source files for the book "NixOS in Production"
Other
485 stars 20 forks source link

nix repl .#<my machine> doesn't work #5

Closed otavio closed 1 year ago

otavio commented 1 year ago

The following part: https://github.com/Gabriella439/nixos-in-production/blob/880c729bf486c5fa7e5b76c45a1e4e64df0ffc56/manuscript/AdvancedModules.md?plain=1#L156-L162 Didn't work for me. It failed when I tried to use my NixOS system as an argument.

Gabriella439 commented 1 year ago

Can you elaborate on that? I tried to reproduce the example locally and it still worked for me

otavio commented 1 year ago

Sure. Few things I believe that are important to understand what causes it:

% nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.2.3, NixOS, 23.05 (Stoat), 23.05.20230310.0c4800d`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `not found`
% nix repl .#nixosConfigurations.micro
warning: future versions of Nix will require using `--file` to load a file
error: getting status of '/home/otavio/src/nix-config/.#nixosConfigurations.micro': No such file or directory

But using the below works:

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

nix-repl> :lf .
Added 15 variables.

nix-repl> nixosConfigurations.micro
{ _module = { ... }; config = { ... }; extendModules = «lambda @ /nix/store/hcyb3afl1n2mdd906yb32c9ivss28msd-source/lib/modules.nix:333:23»; extraArgs = { ... }; options = { ... }; pkgs = { ... }; type = { ... }; }

nix-repl>
otavio commented 1 year ago

The repo in use is https://github.com/otavio/nix-config

I am concerned about why it is different.

Gabriella439 commented 1 year ago

check to make sure that you have the repl-flake experimental-feature enabled in your nix.conf configuration

otavio commented 1 year ago

You're right. Adding a warning about the requirement of the repl-flake option might help. Either way, I am closing this.