To host a local repository for Chocolatey either as server for self-hosted packages or as proxy server for any NuGet server/the official chocolatey repository server we use Solartype Nexus3: sonatype.com - Nexus3. Nexus3 is also useable for hosting a simple, easy-to-manage repository for the APT-package manager.

  1. Download Debian 12 Server from here: debian.org/distrib and install your machine.
  2. Install Java 17:
    sudo apt install openjdk-17-jdk
  3. Add user nexus to run Nexus3:
    adduser nexus
  4. Download the latest Nexus3 from https://help.sonatype.com/en/download.html
  5. Unpack it to /opt/:
    tar xzvf <downloaded-tar-package>.tar.gz -C /opt
  6. Change owner of unpacked files:
    chown nexus -R /opt/nexus-<version>
  7. Make binary executeable:
    chmod +x /opt/nexus-<version>/bin/nexus
  8. Create systemservice with the name nexus.service and copy it to /etc/systemd/system (keep in mind to add the nexus version):

    nexus.service

    [Unit]
    Description=nexus service
    After=network.target
     
    [Service]
    Type=forking
    Environment="NEXUS_SECRETS_KEY_FILE=/opt/sonatype-work/nexus3/keystores/nexus.secrets.json"
    LimitNPROC=65536
    LimitNOFILE=65536
    ExecStart=/opt/nexus-<version>/bin/nexus start
    ExecStop=/opt/nexus-<version>/bin/nexus stop 
    User=nexus
    Restart=on-abort
    TimeoutSec=600
     
    [Install]
    WantedBy=multi-user.target
    cp nexus.service /etc/systemd/system
    systemctl start nexus.service
    systemctl enable nexus.service
  9. When everything was successful, enter the webservice with http://<ip>:8081/
  10. The password for admin is located under /opt/sonatype/sonatype-work/nexus3/admin.password after entering the password, it's forced to be changed.
    cat /opt/sonatype/sonatype-work/nexus3/admin.password

    The installation of Nexus is now finished!

NuGet Proxy

To add a new NuGet (Chocolatey) repository proxy add a new nuget (proxy). To proxy the official Chocolatey repository add the following URL as URL:

https://community.chocolatey.org/api/v2/

Finally save the proxy repository.

NuGet Hosted

If the repository should also host packages locally add a new nuget (hosted).

This section will be extended later.

NuGet Group

To make the proxy-repository and all local hosted packages available through one URL, add a nuget-group on the repository tab. Then add both nuget-proxy and nuget-hosted to the group.

APT Repository (hosted)

  1. Firstly create a GPG-Key for signing the release file:
  2. Therefore install gpg and generate a key with
    gpg --gen-key

    . Then export the key with to paste it under APT Settings:

    gpg --export-secret-key --armor <KEY-ID> > Key.gpg
  3. If your key is password-secured enter the passphrase in the field below.
  4. Then add the name above e.g. apt, and set the distribution e.g. to stable
  5. It's then recommended to upload the public-release-key to a RAW storage to make it easy to download. Therefore export the public key with:
    gpg --armor --export <KEY-ID> > Key.gpg
  6. Finally add the repo to APT:
    echo "deb [signed-by=/usr/share/keyrings/your-repo.gpg] https://<your-repo>/repository/apt/ stable main" | sudo tee /etc/apt/sources.list.d/<your-repo>.list
  7. And add the key:
    curl -sS https://<your-repo>/repository/storage/ReleaseKey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/<your-repo>.gpg > /dev/null
  8. Finished!

Sourced from:

  • windows/chocolatey/setup-self-hosted-choco-repo.txt
  • Last modified: 2025/02/11 08:10
  • by Zyzonix