Files

140 lines
4.3 KiB
Nix
Raw Permalink Normal View History

2025-06-30 01:35:39 -05:00
# A safe, Rust-native binding for the SWORD library
# Copyright (C) 2025 Gregory Hellings
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2025-02-24 10:14:02 -06:00
{
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";
2025-02-24 15:58:46 -06:00
hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
2025-02-24 10:14:02 -06:00
};
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
2025-02-24 20:55:06 -06:00
clippy
libgcc
2025-06-26 02:19:26 -05:00
lldb
2025-02-24 20:55:06 -06:00
rustc.llvm
2025-02-24 10:14:02 -06:00
rustc
rustfmt
pre-commit
2025-02-24 10:42:31 -06:00
sword
2025-02-24 10:14:02 -06:00
];
buildInputs = self'.checks.pre-commit.enabledPackages;
2025-02-24 15:58:46 -06:00
nativeBuildInputs = with pkgs; [
pkg-config
];
2025-02-24 10:14:02 -06:00
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" ];
2025-06-29 22:33:35 -05:00
settings.rust = {
check.cargoDeps = pkgs.rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
cargoManifestPath = "./Cargo.toml";
};
2025-02-24 10:14:02 -06:00
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;
2025-06-29 22:33:35 -05:00
clippy = {
enable = true;
extraPackages = [
pkgs.pkg-config
pkgs.sword
];
};
2025-02-24 10:14:02 -06:00
rustfmt.enable = true;
};
};
};
# This is not special, this is just flakes
packages = rec {
default = rustpkg;
2025-02-24 15:58:46 -06:00
rustpkg = naersk-lib.buildPackage {
src = ./.;
buildInputs = with pkgs; [
sword
];
nativeBuildInputs = with pkgs; [
pkg-config
];
doCheck = true;
};
2025-02-24 10:14:02 -06:00
};
};
};
}