2024-08-10 09:33:15 +00:00
|
|
|
{
|
|
|
|
description = "Backend for GéJDR, a Discord helper tool for the TTRPG L'Anneau Unique";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
|
|
|
|
flake-utils.lib.eachSystem ["x86_64-linux"] (system:
|
|
|
|
let
|
|
|
|
overlays = [ (import rust-overlay) ];
|
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
rustVersion = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
|
|
|
|
rustPlatform = pkgs.makeRustPlatform {
|
|
|
|
cargo = rustVersion;
|
|
|
|
rustc = rustVersion;
|
|
|
|
};
|
|
|
|
|
2024-11-23 09:00:53 +00:00
|
|
|
appNameBackend = "gejdr-backend";
|
|
|
|
appNameBot = "gejdr-bot";
|
2024-08-10 09:33:15 +00:00
|
|
|
|
2024-11-23 09:00:53 +00:00
|
|
|
appRustBuildBackend = rustPlatform.buildRustPackage {
|
|
|
|
pname = appNameBackend;
|
2024-08-10 09:33:15 +00:00
|
|
|
version = "0.1.0";
|
|
|
|
src = ./.;
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
2024-11-23 09:00:53 +00:00
|
|
|
buildPhase = ''
|
|
|
|
cd gejdr-backend
|
|
|
|
SQLX_OFFLINE="1" cargo build --release --bin gejdr-backend
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
cargo install --path . --root "$out/bin/"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
appRustBuildBot = rustPlatform.buildRustPackage {
|
|
|
|
pname = appNameBot;
|
|
|
|
version = "0.1.0";
|
|
|
|
src = ./.;
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
|
|
buildPhase = ''
|
|
|
|
SQLX_OFFLINE="1" cargo build --release --bin gejdr-bot
|
|
|
|
'';
|
2024-08-10 09:33:15 +00:00
|
|
|
};
|
|
|
|
|
2024-11-23 09:00:53 +00:00
|
|
|
dockerImageBackend = pkgs.dockerTools.buildLayeredImage {
|
|
|
|
name = appNameBackend;
|
|
|
|
tag = "latest";
|
|
|
|
config = {
|
|
|
|
Entrypoint = [ "${appRustBuildBackend}/bin/${appNameBackend}" ];
|
|
|
|
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
|
|
|
|
Tag = "latest";
|
|
|
|
};
|
|
|
|
contents = [ appRustBuildBackend pkgs.cacert ];
|
|
|
|
};
|
|
|
|
dockerImageBot = pkgs.dockerTools.buildLayeredImage {
|
|
|
|
name = appNameBot;
|
|
|
|
tag = "latest";
|
|
|
|
fromImageTag = "latest";
|
2024-08-10 09:33:15 +00:00
|
|
|
config = {
|
2024-11-23 09:00:53 +00:00
|
|
|
Entrypoint = [ "${appRustBuildBot}/bin/${appNameBot}" ];
|
2024-08-10 09:33:15 +00:00
|
|
|
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
|
|
|
|
Tag = "latest";
|
|
|
|
};
|
2024-11-23 09:00:53 +00:00
|
|
|
contents = [ appRustBuildBot pkgs.cacert ];
|
2024-08-10 09:33:15 +00:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
packages = {
|
2024-11-23 09:00:53 +00:00
|
|
|
backend = appRustBuildBot;
|
|
|
|
bot = appRustBuildBot;
|
|
|
|
dockerBackend = dockerImageBackend;
|
|
|
|
dockerBot = dockerImageBot;
|
2024-08-10 09:33:15 +00:00
|
|
|
};
|
2024-11-23 09:00:53 +00:00
|
|
|
defaultPackage = dockerImageBackend;
|
2024-08-10 09:33:15 +00:00
|
|
|
devShell = with pkgs; mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
bacon
|
|
|
|
cargo
|
|
|
|
cargo-audit
|
|
|
|
cargo-auditable
|
|
|
|
cargo-tarpaulin
|
|
|
|
just
|
|
|
|
rust-analyzer
|
|
|
|
(rustVersion.override { extensions = [ "rust-src" ]; })
|
|
|
|
sqls
|
|
|
|
sqlx-cli
|
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|