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

nixos-infect crashes with a nix syntax error on scaleway instances #167

Open
vikrem opened this issue Aug 26, 2023 · 0 comments
Open

nixos-infect crashes with a nix syntax error on scaleway instances #167

vikrem opened this issue Aug 26, 2023 · 0 comments

Comments

@vikrem
Copy link

vikrem commented Aug 26, 2023

  1. Add some ssh keys to your scaleway account
  2. Start a fresh instance on scaleway. I'm using an AMP2 instance with Debian 12, but it likely doesn't matter.
  3. Ssh into the machine and run nixos infect: curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | bash -x
  4. 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.

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

No branches or pull requests

1 participant