Skip to content

Comments

feat(weller): add bootstrap configuration for two-stage install#293

Open
patflynn wants to merge 6 commits intomainfrom
feat/weller-bootstrap
Open

feat(weller): add bootstrap configuration for two-stage install#293
patflynn wants to merge 6 commits intomainfrom
feat/weller-bootstrap

Conversation

@patflynn
Copy link
Owner

This PR introduces a two-stage installation process for the 'weller' host to resolve issue #263.

Changes:

  • Refactored 'hosts/weller/default.nix' to extract hardware config to 'hosts/weller/hardware.nix'.
  • Created 'modules/bootstrap.nix' for initial mutable install with SSH enabled and no secrets.
  • Added 'weller-bootstrap' nixosConfiguration to 'flake.nix'.

Usage:

  1. Install 'weller-bootstrap' (no secrets required, SSH enabled).
  2. Boot into the new system, generate/copy SSH host keys, and rekey secrets.
  3. Switch to the full 'weller' configuration.

- Refactor 'hosts/weller/default.nix' to extract hardware config to 'hosts/weller/hardware.nix'.
- Create 'modules/bootstrap.nix' for initial mutable install with SSH enabled and no secrets.
- Add 'weller-bootstrap' nixosConfiguration to 'flake.nix'.

Fixes #263
@gemini-code-assist
Copy link

Summary of Changes

Hello @patflynn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes a robust two-stage installation workflow for the 'weller' host, addressing issue #263. It separates hardware-specific settings into a dedicated file and introduces a temporary bootstrap configuration. This allows for an initial system setup with SSH access and mutable users, facilitating the subsequent transition to the full, secure 'weller' configuration.

Highlights

  • Two-stage installation: Implemented a two-stage installation process for the 'weller' host to resolve issue weller setup friction log. #263.
  • Hardware configuration extraction: Extracted hardware-specific configurations from 'hosts/weller/default.nix' into a new 'hosts/weller/hardware.nix' file for better modularity.
  • Bootstrap configuration: Introduced a 'weller-bootstrap' NixOS configuration in 'flake.nix' and a corresponding 'modules/bootstrap.nix' for an initial mutable install with SSH enabled and no secrets.
Changelog
  • flake.nix
    • Added 'weller-bootstrap' NixOS configuration.
  • hosts/weller/default.nix
    • Removed 'lib' import.
    • Replaced direct hardware configuration with an import of './hardware.nix'.
  • hosts/weller/hardware.nix
    • Created to house hardware-specific configurations for the 'weller' host.
  • modules/bootstrap.nix
    • Created to define a bootstrap module, enabling SSH, mutable users, and setting a default initial password.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

- Add 'mkBootstrap' helper function to flake.nix for easy creation of bootstrap images for any host.
- Update 'modules/bootstrap.nix' to use 'lib.mkDefault' for user options, allowing overrides.
- Use 'mkBootstrap' for 'weller-bootstrap' configuration.
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a two-stage installation process for the 'weller' host, effectively decoupling the initial setup from secret management, and refactors hardware configuration into a dedicated file for modularity. However, the new bootstrap module introduces critical security vulnerabilities, including a hardcoded default password and overly permissive SSH and sudo settings, which must be addressed to minimize the risk of compromise during the initial setup phase. Additionally, consider using distinct hostnames for the bootstrap and final configurations to improve clarity.

"networkmanager"
"video"
];
initialPassword = "nixos";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The initialPassword for the default user is set to a hardcoded, well-known value (nixos). This is a significant security vulnerability as it allows anyone with network access to the system during the bootstrap phase to log in via SSH, potentially gaining immediate root privileges if passwordless sudo is also enabled. Hardcoding passwords in source code, even for bootstrap, is a security risk.

Comment on lines 24 to 47
PermitRootLogin = "yes";
PasswordAuthentication = true;
};
};

# Mutable users for bootstrap
users.mutableUsers = true;

users.users.root.openssh.authorizedKeys.keys = keys.users;

users.users.${config.cosmo.user.default} = {
isNormalUser = true;
uid = 1000;
extraGroups = [
"wheel"
"networkmanager"
"video"
];
initialPassword = "nixos";
openssh.authorizedKeys.keys = keys.users;
};

# Make it easy to assume root during bootstrap
security.sudo.wheelNeedsPassword = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The bootstrap configuration enables SSH root login (PermitRootLogin = "yes"), password authentication (PasswordAuthentication = true), and allows the wheel group to use sudo without a password (security.sudo.wheelNeedsPassword = false). These settings significantly increase the attack surface and risk of unauthorized access if the system is exposed to a network. Since SSH keys are already configured, it is recommended to disable password-based authentication to improve security.

      PermitRootLogin = "prohibit-password";
      PasswordAuthentication = false;

# ---------------------------------------------------------------------------
# Networking
# ---------------------------------------------------------------------------
networking.hostName = "weller";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The hostname is hardcoded to "weller" in this shared hardware.nix file. This means the weller-bootstrap configuration will also have the hostname "weller", which could be confusing during the two-stage installation. It's generally better for each system configuration to define its own hostname.

I recommend removing this line from the shared hardware configuration. Then, you should add networking.hostName = "weller"; to hosts/weller/default.nix and networking.hostName = "weller-bootstrap"; to modules/bootstrap.nix to ensure each configuration has a distinct and appropriate hostname.

- Update Weller setup guide with Stage 1 (bootstrap) and Stage 2 (full) steps.
- Explain usage of 'weller-bootstrap' flake target.
- Document the SSH key generation and secret rekeying workflow.
- Disable password-based SSH and root login for bootstrap.
- Remove hardcoded default 'nixos' password; use repo SSH keys instead.
- Require sudo password by default in bootstrap for better security.
- Move weller hostname definition to default.nix to resolve CI conflict.
- Refactor classic-laddie to use hardware.nix for better modularity.
- Add classic-laddie-bootstrap to flake.nix.
- Support networking.hostId in mkBootstrap for ZFS hosts.
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

Successfully merging this pull request may close these issues.

1 participant