ofborg/default.nix

128 lines
3 KiB
Nix
Raw Normal View History

{ sources ? import ./npins, pkgs ? import sources.nixpkgs {} }:
{
overlay = self: super:
let
inherit (super) lib;
in
{
ofborg = super.rustPlatform.buildRustPackage {
name = "ofborg";
src = super.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = with pkgs; [
pkg-config
rustPackages.clippy
];
buildInputs = lib.optionals super.stdenv.isDarwin (with pkgs; [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
]);
preBuild = ''
cargo clippy
'';
doCheck = false; # Tests require access to a /nix/ and a nix daemon
checkInputs = with super; [
lix
];
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hubcaps-0.6.2" = "sha256-yyHOCxUsehvtYfttRY4T9TDrJhSKGpJRa/SX3Sd1TNc=";
};
};
};
};
packages = {
ofborg = pkgs.rustPlatform.buildRustPackage {
name = "ofborg";
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = with pkgs; [
pkg-config
rustPackages.clippy
];
buildInputs = with pkgs; [
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
]);
preBuild = ''
cargo clippy
'';
doCheck = false; # Tests require access to a /nix/ and a nix daemon
checkInputs = with pkgs; [
lix
];
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hubcaps-0.6.2" = "sha256-yyHOCxUsehvtYfttRY4T9TDrJhSKGpJRa/SX3Sd1TNc=";
};
};
};
};
shell = pkgs.mkShell {
name = "ofborg-devenv";
RABBITMQ_CONFIG_FILE = pkgs.writeText "rabbitmq-dev.conf" ''
listeners.tcp.1=:::5672
'';
TRIVIAL_PASSWORD = pkgs.writeText "trivial-password.txt" "test";
RABBITMQ_LOGS = "-";
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
packages = with pkgs; [
lix
gitFull
nix-prefetch-git
rustc
cargo
2024-11-16 15:47:28 +00:00
cargo-edit
cargo-outdated
clippy
rustfmt
pkg-config
rabbitmq-server
hivemind
];
postHook = ''
checkPhase() (
cd "${builtins.toString ./.}/ofborg"
set -x
cargo fmt
git diff --exit-code
cargofmtexit=$?
cargo clippy
cargoclippyexit=$?
cargo build && cargo test
cargotestexit=$?
sum=$((cargofmtexit + cargoclippyexit + cargotestexit))
exit $sum
)
'';
shellHook = ''
export RABBITMQ_MNESIA_BASE="$(git rev-parse --show-toplevel)/.rabbitmq-data";
export STATE_DIRECTORY="$(git rev-parse --show-toplevel)/.ofborg-state"
mkdir -p "$STATE_DIRECTORY"
mkdir -p "$RABBITMQ_MNESIA_BASE"
'';
RUSTFLAGS = "-D warnings";
RUST_BACKTRACE = "1";
RUST_LOG = "ofborg=debug";
NIX_PATH = "nixpkgs=${pkgs.path}";
};
}