67 lines
2.1 KiB
Nix
67 lines
2.1 KiB
Nix
{
|
|
description = "Application packaged using dream2nix";
|
|
|
|
inputs.nixpkgs.follows = "dream2nix/nixpkgs";
|
|
inputs.dream2nix.url = "github:nix-community/dream2nix";
|
|
|
|
outputs = { self, nixpkgs, flake-utils, dream2nix }:
|
|
(flake-utils.lib.eachDefaultSystem (system:
|
|
let pkgs = nixpkgs.legacyPackages.${system};
|
|
in {
|
|
packages = {
|
|
default = dream2nix.lib.evalModules {
|
|
modules = [
|
|
{
|
|
deps.python = pkgs.python311;
|
|
paths = {
|
|
projectRoot = ./.;
|
|
projectRootFile = "pyproject.toml";
|
|
package = ".";
|
|
};
|
|
}
|
|
./package.nix
|
|
];
|
|
packageSets.nixpkgs = pkgs;
|
|
};
|
|
};
|
|
|
|
devShells.default =
|
|
self.packages.${system}.default.devShell.overrideAttrs (o: {
|
|
nativeBuildInputs = o.nativeBuildInputs
|
|
++ [ pkgs.ruff pkgs.black pkgs.pyright ];
|
|
});
|
|
})) // {
|
|
nixosModules.default = { config, pkgs, lib, ... }:
|
|
let cfg = config.services.yobot;
|
|
in {
|
|
options.services.yobot = with lib; {
|
|
enable = mkEnableOption "enable yobot";
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = self.packages.${pkgs.system}.default;
|
|
};
|
|
configFile = mkOption { type = types.path; };
|
|
};
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.yobot = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
environment.YOBOT_CONFIG = "%d/config.toml";
|
|
serviceConfig = {
|
|
ExecStart = "${cfg.package}/bin/yobot bot";
|
|
DynamicUser = true;
|
|
Type = "simple";
|
|
LoadCredential = "config.toml:${cfg.configFile}";
|
|
RestartSteps = 20;
|
|
Restart = "on-failure";
|
|
};
|
|
unitConfig = {
|
|
StartLimitIntervalSec = 300;
|
|
StartLimitBurst = 5;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
};
|
|
}
|