Gitea On NixOS With Docker

There is no need for a long introduction here. This is the contents of my gitea.nix file. All of the data is saved on an external (encrypted) SSD, called /media.

{ config, pkgs, ... }:

{

  # Gitea
  virtualisation.oci-containers.containers."gitea" = {
    autoStart = true;
    image = "gitea/gitea:latest";
    environment = {
      USER_UID = "1000";
      USER_GID = "1000";
    };
    volumes = [
      "/media/Containers/Gitea:/data"
      "/etc/timezone:/etc/timezone:ro"
      "/etc/localtime:/etc/localtime:ro"
    ];
    ports = [
      "3000:3000"
      "222:22"
    ];
  };

}

Since that's in its own .nix file, we need to add it to the imports section of the /etc/nixos/configuration.nix, like so:

imports = [
  ./hardware-configuration.nix
  # Docker containers
  ./containers/gitea.nix
];

That's it! Run sudo nixos-rebuild switch and, once it downloads and starts, you should have a running Gitea container on your NixOS box!

My YouTube Channel

<< Articles