Describe the bug
Before it was possible to use to use nix repl <nixpkgs/nixos> to get nixos in a repl.
This seems not possible anymore with flakes nix repl ".#":
Welcome to Nix version 2.4pre20200622_334e26b. Type :? for help.
Loading '.#'...
error: --- SysError ----------------------------------------------------------- nix
getting status of '/home/joerg/.homesick/repos/dotfiles/.#': No such file or directory
How do I load flakes in a nix repl?
Current workaround:
cat > ./nixos-config.nix <<EOF
(builtins.getFlake (toString ./.)).nixosConfigurations.turingmachine
EOF
nix repl ./nixos-config.nix
FWIW, if a snippet like this in your flake.nix you can also do nix run .#repl:
{
outputs = { flake-utils, ... }: {
apps.repl = flake-utils.lib.mkApp {
drv = pkgs.writeShellScriptBin "repl" ''
confnix=$(mktemp)
echo "builtins.getFlake (toString $(git rev-parse --show-toplevel))" >$confnix
trap "rm $confnix" EXIT
nix repl $confnix
'';
};
};
}
Most helpful comment
FWIW, if a snippet like this in your
flake.nixyou can also donix run .#repl: