How to Install Woodpecker on NixOS Latest
Woodpecker is a continuous integration tool that can help you automate your software development process. In this tutorial, we will guide you through the steps to install Woodpecker on NixOS Latest.
Prerequisites
Before we start, make sure that you have access to an instance of NixOS Latest that you want to install Woodpecker on. You should also have root privileges to install packages.
Step 1: Add Woodpecker to NixOS Configuration File
The first step is to add the Woodpecker package to your NixOS configuration file. You can do this by adding the following line to your configuration.nix file:
{ config, pkgs, ... }:
{
# ...
environment.systemPackages = with pkgs; [
# ...
woodpecker
];
}
Make sure to replace # ... with the existing configuration.
Save the changes to the configuration file and rebuild the system by running the following command:
$ sudo nixos-rebuild switch
Step 2: Configure Woodpecker
Once you have installed Woodpecker, the next step is to configure it. You need to create a configuration file in /etc/woodpecker/ directory. You can use the following configuration as a starting point:
# /etc/woodpecker/config.toml
[general]
log_level = "info"
src_root = "/srv/git/"
working_dir = "/var/lib/woodpecker/working_dir"
[web]
enable = true
bind = "127.0.0.1:8080"
theme = "default"
templates_path = "/etc/woodpecker/templates/"
[database]
engine = "sqlite"
dsn = "/var/lib/woodpecker/woodpecker.db"
[[build]]
db_name = "default"
storage_path = "/var/lib/woodpecker/storage/"
build_runner = "/usr/bin/bash"
build_script = "${GLOBAL_CONFIG_SRCROOT}/build.sh {commit_id} {build_id}"
In the above configuration:
log_leveldefines the logging level for Woodpecker.src_rootspecifies the directory where the Git repositories are stored.working_diris the directory where Woodpecker executes jobs.webcontains the settings for the web interface.databasecontains the settings for the database.buildis an example build configuration. You can have multiple build configurations by adding more[[build]]blocks.
Make sure the directories and files mentioned in the configuration file exist.
Step 3: Start Woodpecker
Once you have configured Woodpecker, the final step is to start it. You can do this by running the following command:
$ sudo systemctl enable --now woodpecker
This command enables and starts the Woodpecker service. You can check the status of the service by running the following command:
$ sudo systemctl status woodpecker
If everything is configured correctly, you should see output indicating that the service is active (running).
Conclusion
Congratulations! You have successfully installed Woodpecker on NixOS Latest and configured it. You can now use Woodpecker as a continuous integration tool for your software development projects.