Nixflix Introduction - Media Server Declaration

I would like to introduce a project I have been working on for the past several months. It is a NixOS module for declarative media server management called Nixflix.

My most dreaded part of setting up a new media management server is configuring all of the connective tissue of many services that are part of a media management solution. So, I made something to do it for me. GitHub - kiriwalawren/nixflix: NixOS Media Server Configuration

I should note that only jellyfin is supported right now. But if anyone want to take a crack at introducing support for another media streamer service, please feel free to. Otherwise, I hope the rest of you find this useful, even if only for your personal configurations.

28 Likes

Very cool! I will certainly try this out when time allows.

1 Like

This looks great! I’m trying to do something very similar with a slightly different use case (no arr stack except wizarr for user signups), but I’ll definitely look this over for ideas!

Hey, that’s really cool! Good work!

Any stories or fun things you learned during development? Frustrating things?

2 Likes

Thank you! I hope you find it useful!

I my god, so much. What a thoughtful question.

I managed my own media server for 8 years before building this project. I must have recreated that server a handful of times for various reasons (new hardware, different operating system, accidents, etc.) My first iteration on Windows Server! I recently sold it to make room in my life for other things. But that did last long. After about a year, I missed it so much that I decided to build it again. And this is the part I was dreading the most. The configuration of it all. This is the last time. I’m not doing it again, dammit!

I learned about NixOS VM tests! It is amazing that you can have tests for the state of your machine. I cannot get over cool that is. And I love that there is a REPL you can use to interact with the VM after the test has run to investigate the state of the machine. However, it is kind of awkward to use.

I didn’t know much about systemd before I started this project. I only used it a couple times in my personal configurations. So, I learned a lot about that. I’m curious to know if there is a better system. But I haven’t done any research on the topic. I’m falling in love the journalctl. I love that there is one place you can go to easily see the output of any service you are running. No need to guess where it is stored!

My familiarity with the module system was almost non-existent. My personal nix configuration repo has tons of enable options, but that’s about it. Everything I know about options came from this project. While I don’t have anything to rave about with the module system, I am ecstatic that this part of the ecosystem is less mysterious to me.

That said, I would have to say that the most annoying part of this whole experience was the feedback loop. Mine is made worse by the fact that I integrate my home-manger configurations directly into my NixOS configurations. So, if I am making one small change, I am evaluating the whole system again. This problem was made easier by discovering NixOS VM tests, but it is still annoying. I must have recreated a VM from scratch nearly 200 times before learning about NixOS VMs. I scripted it, of course, after about the 20th or 30th. But still…

Thanks for the question. Feel free to ask more!

4 Likes

VM tests are indeed super-neat, but feel sorta underdocumented (or conflictingly documented…the first thing the wiki page says is “these docs are outdated lol”).

Did you have any resources or things you came across or would recommend for folks learning about them for the first time?

1 Like

This is a tough one. Mostly, I learned by doing on this one. I also didn’t know much python before starting this project. So, I had to learn NixOS VM tests, their REPL with special machine.* sauce, and a bit of python.

I don’t really have any resources to point to, but I can say that I didn’t need much to get started. You can be very capable with only knowing machine.wait_for_unit(“my-service.service”, timeout=60), machine.wait_for_open_port(12345, timeout=60), machine.succeed(“echo hello”) (which returns the output that you can store in a python variable and do python things on. This was one of the most useful paradigms for me.

import json
clients = machine.succeed(
    "curl -s -H 'X-Api-Key: 0123456789abcdef0123456789abcdef' "
    "http://127.0.0.1:8989/api/v3/downloadclient"
)
clients_list = json.loads(clients)

Which I could easily write python assertions against. I’m sorry I don’t have a better answer, but I did write a little primer to tests in the form of a readme here: nixflix/tests at main · kiriwalawren/nixflix · GitHub

Edit: I forgot about these

That’s all I got, though.

I don’t think the tests I wrote even scratch the surface of what is possible here.

1 Like

I’ve been procrastinating the setup of my media server beyond installing jellyfin exactly because all this configuration you talking about, I will definitely try you project