68 lines
1.9 KiB
Nix
68 lines
1.9 KiB
Nix
{
|
|
description = "Description for the project";
|
|
|
|
inputs = {
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
crane-flake-parts = {
|
|
url = "github:bluepython508/crane-flake-parts";
|
|
inputs.rust-overlay.follows = "rust-overlay";
|
|
};
|
|
};
|
|
|
|
outputs = inputs @ {
|
|
self,
|
|
flake-parts,
|
|
crane-flake-parts,
|
|
...
|
|
}:
|
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
|
imports = [
|
|
crane-flake-parts.flakeModules.default
|
|
];
|
|
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
|
|
crane.source = ./.;
|
|
perSystem = {pkgs, ...}: {
|
|
crane.packages.default.buildInputs = [pkgs.sqlite];
|
|
crane.shell.args.packages = [pkgs.sqlite-interactive];
|
|
};
|
|
|
|
flake.nixosModules.default = {
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
pkg = self.packages.${pkgs.system}.default;
|
|
cfg = config.bluepython508.botc-mover;
|
|
in {
|
|
options.bluepython508.botc-mover = with lib; {
|
|
enable = mkEnableOption "botc-mover";
|
|
tokenFile = mkOption {
|
|
type = types.path;
|
|
};
|
|
};
|
|
config.systemd.services.botc-mover = lib.mkIf cfg.enable {
|
|
description = "BotC Mover";
|
|
environment = {
|
|
DB_FILE = "/var/lib/botc-mover/db.sqlite";
|
|
DISCORD_TOKEN_FILE = "%d/discord-token";
|
|
RUST_BACKTRACE = "1";
|
|
};
|
|
wantedBy = ["multi-user.target"];
|
|
script = "${pkg}/bin/botc-mover";
|
|
|
|
serviceConfig = {
|
|
LoadCredential = ["discord-token:${cfg.tokenFile}"];
|
|
DynamicUser = true;
|
|
StateDirectory = "botc-mover";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|