Add nixos module
This commit is contained in:
46
flake.nix
46
flake.nix
@@ -14,16 +14,54 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs@{ flake-parts, crane-flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
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" ];
|
||||
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 pkgs.sqlx-cli];
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user