Skip to content

pedorich-n/playit-nixos-module

Repository files navigation

NixOS module for Playit Agent

This NixOS module provides two things:

  • packaged playit-agent using crane
  • a service defintion to run playit-agent as systemd service

Usage

Example flake.nix:

{
  # Optional step. Binary cache to improve the build time
  nixConfig = {
    extra-substituters = [ "https://playit-nixos-module.cachix.org" ];
    extra-trusted-public-keys = [ "playit-nixos-module.cachix.org-1:22hBXWXBbd/7o1cOnh+p0hpFUVk9lPdRLX3p5YSfRz4=" ];
  };

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    playit-nixos-module.url = "github:pedorich-n/playit-nixos-module";
  }

  output = { nixpkgs, playit-nixos-module }: {
    nixosConfigurations = {
      example = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          playit-nixos-module.nixosModules.default
          ./configuration.nix
        ];
      };
    };
  }
}

Setup service:

{ config, ... }: {
  services.playit = {
    enable = true;
    user = "playit";
    group = "playit";
    secretPath = config.age.secrets.playit-secret.path;
    runOverride = {
      "890e3610-26cd-4e2b-b161-7cf0e4f69148".port = 8080;
      "177485db-47aa-4fa9-9ccf-411ab761b9f0" = { ip = 192.168.1.1; port = 9000; };
    };
  };
}

Obtaining a secret

Run

nix run github:pedorich-n/playit-nixos-module#playit-cli -- claim generate

This will output a code, use this code in next command

nix run github:pedorich-n/playit-nixos-module#playit-cli -- claim exchange <code>

Follow the link and approve the agent on the website. After that plait-cli will output a secret to the console. Use this secret to create a TOML file like

secret_key = "<secret>"

It is recommended to use secret manager like agenix or sops to avoid having exposed secret in /nix/store

Documentation

To see latest documentation run

nix run github:pedorich-n/playit-nixos-module#docs.serve