===== Setup self hosted Chocolatey Repository/Proxy on Linux =====
To host a local repository for [[https://chocolatey.org|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: [[https://www.sonatype.com/products/sonatype-nexus-repository|sonatype.com - Nexus3]].  Nexus3 is also useable for hosting a simple, easy-to-manage repository for the APT-package manager.
==== Installation ====
  - Download Debian 12 Server from here: [[https://www.debian.org/distrib/|debian.org/distrib]] and install your machine.
  - Install Java 17: sudo apt install openjdk-17-jdk
  - Add user ''nexus'' to run Nexus3: adduser nexus
  - Download the latest Nexus3 from ''https://help.sonatype.com/en/download.html''
  - Unpack it to ''/opt/'': tar xzvf .tar.gz -C /opt
  - Change owner of unpacked files: chown nexus -R /opt/nexus-
  - Make binary executeable: chmod +x /opt/nexus-/bin/nexus
  - Create systemservice with the name ''nexus.service'' and copy it to ''/etc/systemd/system'' (keep in mind to add the nexus version): 
[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-/bin/nexus start
ExecStop=/opt/nexus-/bin/nexus stop 
User=nexus
Restart=on-abort
TimeoutSec=600
  
[Install]
WantedBy=multi-user.target
cp nexus.service /etc/systemd/systemsystemctl start nexus.servicesystemctl enable nexus.service
  - When everything was successful, enter the webservice with ''http://:8081/''
  - 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!
==== Setup Repository ====
=== 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) ===
  - Firstly create a GPG-Key for signing the release file: 
  - 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.gpg   
  - If your key is password-secured enter the passphrase in the field below.
  - Then add the name above e.g. ''apt'', and set the distribution e.g. to ''stable''
  - 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.gpg
  - Finally add the repo to APT: echo "deb [signed-by=/usr/share/keyrings/your-repo.gpg] https:///repository/apt/ stable main" | sudo tee /etc/apt/sources.list.d/.list
  - And add the key: curl -sS https:///repository/storage/ReleaseKey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/.gpg > /dev/null
  - Finished!
-----
//Sourced from://
  * //[[https://github.com/sonatype-nexus-community/nexus-repository-installer|github.com/sonatype-nexus-community]]//
  * //[[https://www.howtoforge.com/how-to-install-nexus-repository-manager-on-ubuntu-22-04/|howtoforge.com - install Nexus3 on Ubuntu22]]//
  * //[[https://stackoverflow.com/questions/45867716/nexus-to-serve-up-chocolately-packages|stackoverflow.com - Nexus serve up chocolatey]]//