Update init.sh

This commit is contained in:
2026-01-22 11:18:44 -07:00
parent 285b8f3799
commit 0880a73d46

View File

@@ -37,12 +37,20 @@ fi
echo -e "${GREEN}Repository is in correct location: $TARGET_DIR${NC}" echo -e "${GREEN}Repository is in correct location: $TARGET_DIR${NC}"
echo "" echo ""
if [ -f "/etc/nixos/hardware-configuration.nix" ]; then if [ ! -f "$TARGET_DIR/hardware-configuration.nix" ]; then
cp /etc/nixos/hardware-configuration.nix "$TARGET_DIR/hardware-configuration.nix" if [ -f "/etc/nixos/hardware-configuration.nix" ]; then
echo -e "${GREEN}Copied hardware-configuration.nix${NC}" cp /etc/nixos/hardware-configuration.nix "$TARGET_DIR/hardware-configuration.nix"
echo -e "${GREEN}Copied hardware-configuration.nix from /etc/nixos${NC}"
elif [ -f "/etc/nixos.bak/hardware-configuration.nix" ]; then
cp /etc/nixos.bak/hardware-configuration.nix "$TARGET_DIR/hardware-configuration.nix"
echo -e "${GREEN}Copied hardware-configuration.nix from /etc/nixos.bak${NC}"
else
echo -e "${YELLOW}Generating hardware-configuration.nix...${NC}"
sudo nixos-generate-config --show-hardware-config > "$TARGET_DIR/hardware-configuration.nix"
echo -e "${GREEN}Generated hardware-configuration.nix${NC}"
fi
else else
echo -e "${YELLOW}No hardware-configuration.nix found${NC}" echo -e "${GREEN}hardware-configuration.nix already exists${NC}"
echo "Run 'sudo nixos-generate-config' first if this is a fresh install"
fi fi
if [ -L "$NIXOS_DIR" ]; then if [ -L "$NIXOS_DIR" ]; then
@@ -56,10 +64,17 @@ fi
echo "Creating symlink: $TARGET_DIR -> $NIXOS_DIR" echo "Creating symlink: $TARGET_DIR -> $NIXOS_DIR"
sudo ln -sf "$TARGET_DIR" "$NIXOS_DIR" sudo ln -sf "$TARGET_DIR" "$NIXOS_DIR"
if [ -d "$TARGET_DIR/.git" ]; then
echo ""
echo -e "${GREEN}Initializing git repository...${NC}"
cd "$TARGET_DIR"
git add .
echo -e "${GREEN}Files staged for commit${NC}"
fi
echo "" echo ""
echo -e "${GREEN}Setup complete!${NC}" echo -e "${GREEN}Setup complete!${NC}"
echo "" echo ""
echo "Next steps:" echo "Next steps:"
echo " 1. Ensure hardware-configuration.nix exists in $TARGET_DIR" echo " 1. Review the configuration files"
echo " 2. Run 'git add .' to track files (required for flakes)" echo " 2. Run 'sudo nixos-rebuild switch --flake .#lavitz' to apply"
echo " 3. Run 'sudo nixos-rebuild switch --flake .#lavitz'"