Nix Deployment

Nixi integrates seamlessly with Nix for reproducible, declarative deployments. This guide covers nix run, nix build, and Flakes.

Quick Start with Nix

Clone the repository and enter the development environment:

# Clone and run
git clone https://github.com/ijadux2/nixi.git
cd nixi

# Enter development environment (recommended)
nix develop .

# Start the server
lua server.lua

# Or with live reload
lua server.lua --watch

Using shell.nix (Legacy)

The project includes a shell.nix for traditional Nix users:

# Enter development environment
nix-shell

# Or with custom path
nix-shell shell.nix

# Then run the server
lua server.lua

Shell Features

The development shell includes:

Flake Integration

For modern Nix with flakes enabled, use flake.nix:

# Enter development shell
nix develop .

# Or specific shell
nix develop .#default
nix develop .#minimal

# Build the project
nix build

# Run the built binary
./result/bin/nixi

Available Shells

ShellDescription
defaultFull development environment with all dependencies
minimalMinimal shell with only Lua + LuaSocket + LuaFileSystem

Adding to Your Project

Reference Nixi in your project's flake:

{
  inputs.nixi.url = "github:ijadux2/nixi";

  outputs = { self, nixpkgs, nixi }: {
    devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
      buildInputs = with nixpkgs.legacyPackages.x86_64-linux; [
        lua5_4
        (lua5_4.withPackages (ps: with ps; [
          luafilesystem
          luasocket
          dkjson
        ]))
        nixi.packages.x86_64-linux.default
      ];
    };
  };
}

Environment Variables

VariableDefaultDescription
NIXI_HOST0.0.0.0Server bind address
NIXI_PORT3000Server port
NIXI_ENVproductionEnvironment mode

Building for Production

# Build the project
nix build

# The binary is at ./result/bin/nixi
./result/bin/nixi new myapp
cd myapp

# Set environment
export NIXI_HOST=0.0.0.0
export NIXI_PORT=3000

# Run
lua server.lua