Skip to content

Cockpit on NixOS setup

Introduction

Cockpit is a cutting-edge web-based graphical interface for server management. It allows you to administer servers effortlessly and includes a built-in terminal.

Personally, I utilize the NixOS package to monitor system logs, network settings, services, system resources, and CPU load and all without needing to touch the command line.

While some features, such as the storage, applications, and software sections, do not work out-of-the-box with NixOS, this does not concern me. I simply use the configuration.nix to make the necessary adjustments.

Cockpit

I have also integrated the Cockpit user interface for managing virtual machines and podman containers. For some time now, I have been contemplating replacing Proxmox with NixOS, and incorporating virtual machines and Podman containers is a crucial part of that transition.

Setup

  1. Add the Cockpit package to configuration.nix

    /etc/nixos/configuration.nix
    # To edit use your text editor application, for example Nano
    environment.systemPackages = with pkgs; [
    cockpit
    ];

    In this case I am using the Cockpit package from the default channel. But you can also use a newer version from the unstable channel (if available).

  2. Then add the Cockpit settings:

    /etc/nixos/configuration.nix
    # To edit use your text editor application, for example Nano
    services.cockpit = {
    enable = true;
    port = 9090;
    # openFirewall = true; # Please see the comments section
    settings = {
    WebService = {
    AllowUnencrypted = true;
    };
    };
    };
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Required Replace port number 9090 with a port number that is available if needed
  3. Switch NixOS configuration

    Now you can switch to the new NixOS configuration. Run the following command:

    # Open your terminal application
    sudo nix-collect-garbage # Optional: clean up
    sudo nixos-rebuild switch
  4. Check the results

    Now you can browse to Cockpit by opening a web browser and going to: http://localhost:9090. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.

Comments

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

    Copyright 2021- Fiction Becomes Fact