Update init.sh
This commit is contained in:
@@ -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 "$TARGET_DIR/hardware-configuration.nix" ]; then
|
||||||
if [ -f "/etc/nixos/hardware-configuration.nix" ]; then
|
if [ -f "/etc/nixos/hardware-configuration.nix" ]; then
|
||||||
cp /etc/nixos/hardware-configuration.nix "$TARGET_DIR/hardware-configuration.nix"
|
cp /etc/nixos/hardware-configuration.nix "$TARGET_DIR/hardware-configuration.nix"
|
||||||
echo -e "${GREEN}Copied hardware-configuration.nix${NC}"
|
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
|
else
|
||||||
echo -e "${YELLOW}No hardware-configuration.nix found${NC}"
|
echo -e "${YELLOW}Generating hardware-configuration.nix...${NC}"
|
||||||
echo "Run 'sudo nixos-generate-config' first if this is a fresh install"
|
sudo nixos-generate-config --show-hardware-config > "$TARGET_DIR/hardware-configuration.nix"
|
||||||
|
echo -e "${GREEN}Generated hardware-configuration.nix${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}hardware-configuration.nix already exists${NC}"
|
||||||
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'"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user