Profile Picture

Assorted tech

Hi, my name is Spencer. I'm a CS graduate focused on systems programming, Linux, and low-complexity design. Other interests: metal, hiking, guitar, rationality.

feed | contact

NixOS/Forgejo Migration: Fix for Missing Users/Repos

Calendar icon March 31, 2024

Clock icon 2 min read

Folder icon #software #nixos #selfhost #git in tech

Migration

TL;DR

If you were using sqlite (NixOS default), copy your Gitea database over the auto-generated blank Forgejo database with cp /var/lib/forgejo/data/gitea.db /var/lib/forgejo/forgejo.db.

Complete Instructions

I decided to switch from self-hosting Gitea to Forgejo for reasons. To start, I followed official migration instrucitons but did a few things differently on account of running NixOS:

  1. systemctl stop gitea
  2. Do NOT copy app.ini (it isn’t there, it’s part of your system nix config and will be built automatically)
  3. Perform data migration as noted
  4. Switch services.gitea section in your system config to services.forgejo.
  5. nixos-rebuild switch

After doing this, I could access the interface but my existing users and repos were missing. The reason I’m writing this article is to let you know that you need to copy /var/lib/forgejo/data/gitea.db to /var/lib/forgejo/data/forgejo.db. There will be a forgejo.db file in place without your data.

To continue with the steps:

  1. systemctl stop forgejo
  2. cp /var/lib/forgejo/data/gitea.db /var/lib/forgejo/forgejo.db
  3. systemctl start forgejo

If your setup is the same as mine:

The last thing I did was select the default Forgejo theme in my users settings.

Hopefully this saves you a few minutes.

Comments