Files
sword_rs/flake.nix
T
Greg Hellings 0ec0a0c7ac Builds, runs, and tests succeed*
*Tests only succeed if you run them in a single-threaded instance. With
cargo this means invoking them as `cargo run -- --test-threads=1`. There
is an instance of global state in the Sword engine with the
VersificationMgr class that can easily cause a race condition. Since
VersificationMgr is intended to be a global singleton, when it is first
being instantiated the pointer is null. Sometimes the tests get into
that method at the same time and overwrite one another with the instance
of the manager, thus causing some of the VerseKeys that get instantiated
to be invalid.

TODO: On the Rust side of the code, create an instance of the
VersificationMgr before allowing any VerseKey objects to be created.
Probably also necessary to run it before allowing SWMgr to be
instantiated, as well, just to be safe.
2025-06-26 02:19:26 -05:00

116 lines
3.3 KiB
Nix

# github.com/brianmcgee has lots of great ideas for going above and beyond for this
{
description = "Greg's homepage";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.flake-root.flakeModule
];
flake = {
# Universal things
overlays.default = _final: _prev: { };
};
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
perSystem =
{ pkgs, self', ... }@inputs':
let
naersk-lib = pkgs.callPackage inputs.naersk { };
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit (inputs') system;
overlays = [ ];
};
devShells.default = pkgs.mkShell rec {
# These will just be available
packages = with pkgs; [
cargo
clippy
libgcc
lldb
rustc.llvm
rustc
rustfmt
pre-commit
sword
];
buildInputs = self'.checks.pre-commit.enabledPackages;
nativeBuildInputs = with pkgs; [
pkg-config
];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
inherit (self'.checks.pre-commit) shellHook;
# This is also used when building with iced
# let
# lib_path = builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" packages;
# in
# ''
# export LD_LIBRARY_PATH="${lib_path}"
# ''
};
checks = {
pre-commit = inputs.hooks.lib.${inputs'.system}.run {
src = ./.;
excludes = [ ".*\\.txt" ];
hooks = {
check-added-large-files.enable = true;
check-case-conflicts.enable = true;
check-merge-conflicts.enable = true;
check-symlinks.enable = true;
deadnix.enable = true;
end-of-file-fixer.enable = true;
fix-byte-order-marker.enable = true;
mixed-line-endings.enable = true;
nixfmt-rfc-style.enable = true;
trim-trailing-whitespace.enable = true;
# Rust hooks
cargo-check.enable = true;
clippy.enable = true;
rustfmt.enable = true;
};
};
};
# This is not special, this is just flakes
packages = rec {
default = rustpkg;
rustpkg = naersk-lib.buildPackage {
src = ./.;
buildInputs = with pkgs; [
sword
];
nativeBuildInputs = with pkgs; [
pkg-config
];
doCheck = true;
};
};
};
};
}