I use NixOS for my home-server, and you should too!
Tags: nixos, linux, homeserver, homelab
Published: 2024-04-22 00:37:36

As we covered in my [last post](https://dev.to/jasper-at-windswept/this-distro-finally-fixes-linux-1ac9), [NixOS](https://nixos.org) is a amazing Linux distribution for creating stable and declared environments. Now while this is amazing for a desktop setup, it is also perfect for a home-server or home-lab. 

Let's take a look at a few ways NixOS makes setting up a home-server so much smoother!

## Self Hosting Services

NixOS has gained many integrations from a wide variety of services over the years but here are a few you will probably be interested in.

### Jellyfin


![Jellyfin Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zjorb1sehsa47va842q.png)


Out of the box NixOS provides options to easily setup a Jellyfin instance on your computer, just add the following to your `configuration.nix`

```nix
services.jellyfin = {
  enable = true;
  dataDir = "/home/your-user/jellyfin/data";
  user = "your-user";
};
```

It is that easy to spin up a fresh instance of Jellyfin and there are even more options all found on [search.nixos.org](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=jellyfin)

### Vaultwarden


![Vaulwarden banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zi63vwc98qlennztsa2i.png)



Never before has it been this easy to setup Vaultwarden, a fork of the Bitwarden server with all the features of a paid Bitwarden account!

```nix
services.vaultwarden = {
  enable = true;
  dbBackend = "postgresql";
  # Store your variables like admin password here
  environmentFile = "/home/your-user/vaultwarden/.env";
  config = {
    SIGNUPS_ALLOWED = false;
    DOMAIN = "https://vaultwarden.example.com";
  };
};
```

There are even more options than these though so again make sure to checkout [search.nixos.org](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=vaultwarden)

### Nextcloud


![Nextcloud Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nn0n2x9p7hka3g9mimfz.png)



Here we are the big boy himself, Nextcloud.
Of course like all the other popular self hosted services Nextcloud has a large variety of options to get your services up and running.

```nix
services.nextcloud = {
  enable = true;
  home = "/home/your-user/nextcloud";
  https = true;
  hostname = "nextcloud.example.com";
  settings = {
    trusted_domains = [
      "talk.nextcloud.example.com"
      "files.nextcloud.example.com"
    ];
  };
};
```

And for the final time those are just a fraction of the available options to configure Nextcloud through NixOS, so if you need to configure anything else make sure to check out [search.nixos.org/nextcloud](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=services.nextcloud).

So have I convinced you yet? NixOS really is the easiest way to manage all of your software on your desktop and home-server!

But what about Docker, there are some things that NixOS hasn't packaged yet so how do I use those or any of my other docker services?
Well do not worry, NixOS again makes it super simple to setup docker and even setup Nvidia Toolkit support for containers that want GPU utilization.

```nix
virtualisation.docker = {
  enable = true;
  # This option is deprecated and will be replaced 
  # soon but the new option doesn't seem to work 
  # properly yet so you can just use this.
  enableNvidia = true;
};

user.users.your-user = {
  # ...
  extraGroups = [ "docker" ];
  # ...
};
```

Just like that your ready for anything docker to come, and for those who need to configure docker a bit more, maybe put it in rootless mode, can check out the options on [search.nixos.org](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=virtualisation.docker)

## Wrapping Up

Well that was easy wasn't it, just a few lines of code and a rebuild later and you could have all of these services up and at it! 
This is all well but how do you actually get NixOS and set everything up in the first place?

That is exactly what I'm going to help you do, two weeks from now I'll be getting a new home-server and in a new post, or maybe series of posts, I'll go over everything I do to setup NixOS on my system, so make sure to follow me to stay tuned for those!

Another little promotion but if you are interested in NixOS, your just getting started or even if you are more experienced user, I have a documentation site where I publicly write about tons of issues I come across on my journey through NixOS and exactly how I fixed them.

As well I have a ton of resources linked for learning how to get started with NixOS so make sure to check it out at [docs.windswept.digital](https://docs.windswept.digital/)