1. 53
    1. 61

      I’m also using DigitalOcean for a Minecraft server, but with a couple extra features:

      • A small $5 droplet (NixOS) runs a mocked Minecraft protocol handler continuously
      • When a whitelisted player tries to join, it starts another, more powerful and expensive droplet
      • The droplet uses the DigitalOcean NixOS image and attaches /var/lib/minecraft to a volume where the world is stored
      • About ~45 seconds after the attempted join, the machine has booted up and the minecraft server is running, allowing players to join by connecting to the original machine, which just forwards the TCP connection.
      • If the server doesn’t have any connections for 5 minutes, it automatically shuts down

      For my use case of only playing occasionally with some friends this is great, as it allows me to have a powerful server when I need it, without having to pay for its idle time. And anybody that’s whitelisted can start the server, not just me.

      This whole setup uses:

      The final configuration of this whole stack is rather simple: https://github.com/Infinisil/system/blob/master/config/multimods/on-demand-minecraft-setup.nix.

      It currently still requires some manual steps, but I hope to automate that away in the future, ideally ending up with a zero-configuration nix-build && ./result to set up everything (it’s close!) :)

      1. 9

        This is neat as heck. I’ll have to try it out some day!

      2. 1

        Interesting setup, it’s pretty much the poor man’s elastic scaling (0 to 1) of a TCP service, a custom heroku. How did you attach/mount a volume to a droplet? That operation is common for container not droplet(VM).

        1. 1

          It’s just something DigitalOcean allows you to do, see the volume key in https://developers.digitalocean.com/documentation/v2/#create-a-new-droplet (also available from the UI)

    2. 5

      Yesterday I was trying to debug some issue in an open-source project. After some help from the maintainer on what infrastructure is needed (fortunately not much), I run nix-shell -p redis which in a couple seconds let me run redis-server in one console window; then nix-shell -p graphviz in another window (even faster), and started the debugged app with go run in the shell. Several minutes of debugging later I exit-ed both shells and both redis and graphviz were as gone as before - the only extra thing I had to do was delete the database dump redis created in the current directory. When Nix works smoothly it’s so cool!

    3. 4

      I’ve been looking for a reason get more hands on with Nix and this article is a great showcase of how easy it is to setup an environment. Time to figure out how nixos-infect works,

      This script wipes out the targeted host’s root filesystem when it runs to completion.

      Is there a benefit from running NixOS vs. Ubuntu + Nix? Is the latter even possible?

      1. 5

        NixOS lets you undo system upgrades. Ubuntu + Nix lets you roll back software but you don’t get the deep system integration like my post describes.

    4. 4

      Cool writeup!

      What’s the advantage of doing this instead of using, say, Wireguard?

      (Also, neat custom minecraft skin. Very on-brand.)

      1. 8

        From what I understand, Tailscale is basically some fancy glue around Wireguard to make it more convenient like ZeroTier.

        1. 9

          Exactly. It’s like Hamachi for teams in the modern cloud authenticated age.

          1. 7

            Congrats on the new job btw!

            1. 1

              Thanks!

    5. 2

      Is there a particular resource people would recommend for getting up and running with Nix relatively smoothly? It looks pretty neat.

      1. 2
        1. 1

          Thank you!

    6. 1

      New to tailscale, so I’m probably asking something too obvious, but: What’s the purpose of that setup oneshot service? From what I saw in the docs, you only need the one-off key once, so could you “just” run that tailscale up command on the cli as a regular user (with or without the pre-generated key)?

      Do you have to re-run it every time the machine boots?