Skip to content

clone - Repository Cloning

The clone command clones the Nixopus repository with basic configuration options. By default, it clones the main Nixopus repository to a configured local path.

Quick Start

bash
# Clone with default settings (from config)
nixopus clone

# Clone specific branch
nixopus clone --branch develop

# Clone from custom repository
nixopus clone --repo https://github.com/yourfork/nixopus.git

# Preview clone operation
nixopus clone --dry-run

Overview

The clone command provides basic Git repository cloning functionality with configuration-driven defaults for the Nixopus repository.

Command Syntax

bash
nixopus clone [OPTIONS]

Options

OptionShortDescriptionDefault
--repo-rRepository URL to clonehttps://github.com/raghavyuva/nixopus
--branch-bBranch to clonemaster
--path-pLocal path for cloning/etc/nixopus/source
--force-fForce clone (overwrite existing directory)false
--verbose-vShow detailed loggingfalse
--output-oOutput formattext
--dry-run-dPreview clone operation without executingfalse
--timeout-tOperation timeout in seconds10

Examples:

bash
# Basic clone with default configuration
nixopus clone

# Clone specific branch
nixopus clone --branch develop

# Clone from custom repository
nixopus clone --repo https://github.com/yourfork/nixopus.git

# Clone to custom path with force overwrite
nixopus clone --path /opt/nixopus --force

# Preview operation without executing
nixopus clone --dry-run --verbose

# Clone with increased timeout
nixopus clone --timeout 30

Configuration

The clone command reads configuration values from the built-in config.prod.yaml file. Command-line options override these defaults.

Default Configuration Values

SettingDefault ValueConfiguration PathDescription
Repository URLhttps://github.com/raghavyuva/nixopusclone.repoThe Git repository to clone
Branchmasterclone.branchThe Git branch to clone
Clone Path{nixopus-config-dir}/sourceclone.source-pathLocal directory for cloning (relative to config dir)
Config Directory/etc/nixopusnixopus-config-dirBase configuration directory
Timeout10 secondsN/AOperation timeout (hardcoded default)

Configuration Source

The configuration is loaded from the built-in config.prod.yaml file packaged with the CLI. This file contains environment variable placeholders that can be overridden:

yaml
# Built-in configuration (from config.prod.yaml)
nixopus-config-dir: /etc/nixopus
clone:
  repo: "https://github.com/raghavyuva/nixopus"
  branch: "master"
  source-path: source

Overriding Configuration

You can override defaults using command-line options only:

bash
# Override repository URL
nixopus clone --repo https://github.com/yourfork/nixopus.git

# Override branch
nixopus clone --branch develop

# Override clone path (absolute path)
nixopus clone --path /opt/nixopus

# Override multiple options
nixopus clone --repo https://github.com/yourfork/nixopus.git --branch develop --path /custom/path

Note: The clone command does not support user configuration files or environment variable overrides for these settings. Configuration is handled internally through the built-in config file.

Behavior

  1. Validates repository URL and accessibility
  2. Checks if destination path exists
  3. Removes existing directory if --force is used
  4. Clones repository using Git
  5. Reports success or failure

Dry Run Mode

Use --dry-run to preview what the command would do without making changes:

bash
nixopus clone --dry-run --repo custom-repo.git --branch develop

This shows the planned actions without executing them.

Error Handling

Common error scenarios and solutions:

ErrorCauseSolution
Repository not accessibleNetwork issues, invalid URL, or authentication requiredCheck network connection, verify repository URL, or configure Git credentials
Destination path already existsDirectory exists at clone pathUse --force to overwrite or choose different --path
Invalid branch or repository URLBranch doesn't exist or URL is malformedVerify branch exists and URL is correct
Permission deniedInsufficient permissions for destination pathUse sudo nixopus clone or choose a path with write permissions
Timeout exceededClone taking longer than specified timeoutIncrease timeout with --timeout option or check network speed

Permission Issues

If you encounter permission errors when cloning to system directories:

bash
# Use sudo for system-wide installation
sudo nixopus clone --path /opt/nixopus

# Or clone to user directory (recommended)
nixopus clone --path ~/nixopus

Note: When using sudo, the cloned repository will be owned by root. Consider using user directories unless system-wide installation is required.

Made with love
Released under the Functional Source License (FSL)