CCDC Environment setup

linux
windows
_guides
Published

November 15, 2023

This will be the guide(s) on how to set up your environment for CCDC playing, and development of related scripts + testing them.

Windows

This requires Windows 11. With Windows 10, there is no nested virtaulization in Windows Subsystem for Linux (WSL), preventing the use of the relevant vagrant machines.

Although there are workarounds, allowing you to use virtualbox in WSL or the like, they are not worth the effort it requires to support them.

Chocolatey

Install chocolatey here

Using chocolatey, install several packages we need for play/development. If you already have an app installed, you don’t need to install it with chocolatey.

In an administrative powershell or cmd session, run:

choco install -y firefox wezterm vscode

Wezterm

Install wezterm from either chocolatey or the official website (using the setup.)

On a vm, I get an error about the opengl version being incompatible when I attempt to launch wezterm. I have to launch it with `wezterm –config “prefer_egl=true”.

To launch the ubuntu session, you can right click on the new tab, and then a menu will appear, from which you can select Ubuntu.

Ubuntu/WSL in Windows

You need to have Windows 11 installed, in order for nested virtualization within WSL to work. If you are not on Windows 10, then you need to either upgrade, or work within a linux distribution.

As long as you Windows 10 May 2020 Update (version 2004), you can install wsl with a single command. Otherwise, you have to follow some painful steps

In an elevated powershell window:

wsl --install

Reboot the system.

Then, launch wsl with wsl from powershell or cmd.

It’s going to ask you for some prompts. Because this is a development environment, focusing on speed rather than security, I recommend an easy to type username and password.

Edit the sudoers file:

To edit the sudo file, you can use sudo visudo to edit it safely. This command while check the sudoers file for errors, rather than instantly breaking sudo upon a misconfiguration.

/etc/sudoers
# Change the portion of the file referring to env_reset to look like this:
# Put an "!" in front of env_reset, and comment out the part referring to secure path

Defaults        !env_reset
Defaults        mail_badpass
#Defaults       secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 



# Change the portion of the file that refers to the sudo group to look like this:

%sudo ALL=(ALL:ALL) NOPASSWD: ALL

Either reboot, or restart the wsl virtual machine.

To restart the WSL vm, from powershell or cmd:

Install docker and docker-compose (and curl and git, other tools we will need later):

sudo apt update && sudo apt upgrade

sudo apt install docker.io docker-compose curl git openssh-client wget virt-manager

You might have to reboot here, before the next step will work. Maybe.

sudo usermod -aG docker $USER # Run docker without sudo

sudo usermod -aG libvirt $USER # Run libvirt vms without sudo

Rebooting the wsl instance will log you in and out, enabling you to use docker, without sudo, and after you launch virt-manager once, you can access it from the windows gui.

Linux

Linux has many distributions, so I will include vague steps that will work everywhere, rather than precise steps that only work on one distro, like the above Windows/WSL steps, which are designed to work on Ubuntu. If you have an Ubuntu or Debian based distro for your linux, then those steps likely work.

Edit the sudoers file:

To edit the sudo file, you can use sudo visudo to edit it safely. This command while check the sudoers file for errors, rather than instantly breaking sudo upon a misconfiguration.

/etc/sudoers
# Change the portion of the file referring to env_reset to look like this:
# Put an "!" in front of env_reset, and comment out the part referring to secure path

Defaults        !env_reset
Defaults        mail_badpass
#Defaults       secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 

You can also set sudo to not require a password, if you so wish. However, this varies based on distributions.

Install:

  • Equivalent of base development packages for your distro. Usually a metapackage containing git, compilers like gcc, and build tools like make.
  • ssh and related packages. (If sshfs and scp are packaged, get them as well)
  • curl and wget
  • Libvirt and virt-manager (add your user to the libvirtd group so that you don’t need sudo to manage virtual machines)
  • Docker (add your user to the docker group so you don’t need sudo to manage docker containers)
  • Firefox

Wezterm:

Wezterm has official installation instructions. I don’t recommend flatpak, because sandboxing may cause weird behaviors.

Vscode:

Microsoft has an official guide about installing vscode. I recommend you add the microsoft repo for your distro if available, and get from there, so that your package manager can update vscode alongside everything else.

Macos

Install homebrew from the official website

Steps needed:

All Operating Systems

Nix

In macos terminal, in linux, or in WSL, install nix (tool used to manage our development environments):

Do not run these commands with sudo.

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Restart your shell. Simply close and reopen the terminal.

Also, ensure the nix service is enabled by the

Update the nix channels:

nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs

nix-channel --update

Install the zellij terminal multiplexer:

nix profile install nixpkgs#zellij

Vscode

Install these vscode extensions, and their dependencies (should be pulled automatically):

Personal preference, but I like to disable acceptance of the autocomplete suggestion on enter. This can be particularly annoying in languages like ansible or python, where you have to hit enter to go to the next line.

Playing and Developing

Playing

git clone https://github.com/CSUN-CCDC/CCDC-2023

When in the root of this git repo, you can run nix-shell to get a full development environment. It includes tools like ansible, ansible checking, vagrant, and more.