nixos-infect crashes with a nix syntax error on scaleway instances
vikrem opened this issue · 0 comments
vikrem commented
- Add some ssh keys to your scaleway account
- Start a fresh instance on scaleway. I'm using an AMP2 instance with Debian 12, but it likely doesn't matter.
- Ssh into the machine and run nixos infect:
curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | bash -x
- Get this error and the script crashes:
+ NIXOS_CONFIG=/etc/nixos/configuration.nix
+ nix-env --set -I nixpkgs=/root/.nix-defexpr/channels/nixos -f '<nixpkgs/nixos>' -p /nix/var/nix/profiles/system -A system
error:
… while evaluating the attribute 'config.system.build.toplevel'
at /nix/store/s7ml3rrzrkifc5ajrjdrf9i2ncacds8k-nixos-22.11/nixos/lib/modules.nix:346:9:
345| options = checked options;
346| config = checked (removeAttrs config [ "_module" ]);
| ^
347| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/s7ml3rrzrkifc5ajrjdrf9i2ncacds8k-nixos-22.11/nixos/lib/modules.nix:346:18:
345| options = checked options;
346| config = checked (removeAttrs config [ "_module" ]);
| ^
347| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full trace)
error: syntax error, unexpected end of file, expecting IND_STR or DOLLAR_CURLY or IND_STRING_CLOSE
at /etc/nixos/configuration.nix:34:69:
33| ''ssh-ed25519 [redacted]''
34| ''# Below your custom ssh keys from '/root/.ssh/instance_keys'''
| ^
35| ];
This happens because scaleway's default /root/.ssh/authorized_keys
file ends with this line:
# Below your custom ssh keys from '/root/.ssh/instance_keys'
Which ends with a single quote.
When it's copied into the nixos configuration.nix
, a triple-single-quote is placed at the end of the string literal for the ssh keyfile, which breaks the configuration script.
You can work around this by deleting /etc/nixos/configuration.nix
, removing the offending line at the end of /root/.ssh/authorized_keys
, and running the infection script again.