Ozai/flake.nix

84 lines
2.5 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devenv.url = "github:cachix/devenv";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, fenix, nixpkgs, devenv, ... }@inputs:
let
toolchain = fenix.packages.x86_64-linux.minimal.toolchain;
pkgs = import nixpkgs {
system = "x86_64-linux";
};
lib = pkgs.lib;
types = lib.types;
in {
devShell.x86_64-linux = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
{
languages.rust = {
enable = true;
channel = "stable";
};
}
];
};
packages.x86_64-linux.default = (pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
}).buildRustPackage {
pname = "ozai";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
nixosModules = {
ozai = { config, pkgs, ... }: {
options.services.ozai = {
enable = lib.mkEnableOption "Ozai Azul server";
host = lib.mkOption {
type = types.str;
default = "127.0.0.1";
description = "The host to run the server on";
};
port = lib.mkOption {
type = types.int;
default = 8000;
description = "The port to run the server on";
};
};
config = lib.mkIf config.services.ozai.enable {
systemd.services.ozai = {
description = "Ozai Azul server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${self.packages.x86_64-linux.default}/bin/ozai --port ${toString config.services.ozai.port} --host '${config.services.ozai.host}'";
Restart = "always";
};
};
};
};
};
nixosConfigurations = {
ozai = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.ozai
{
system.stateVersion = "23.11";
boot.isContainer = true;
services.ozai.enable = true;
}
];
};
};
};
}