mkspiffs: add Darwin support, modernize derivation (#401924)

This commit is contained in:
Aleksana
2025-05-16 16:02:20 +08:00
committed by GitHub
+28 -10
View File
@@ -2,41 +2,59 @@
lib,
stdenv,
fetchFromGitHub,
pkgsBuildHost,
versionCheckHook,
}:
# Changing the variables CPPFLAGS and BUILD_CONFIG_NAME can be done by
# overriding the same-named attributes. See ./presets.nix for examples.
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "mkspiffs";
version = "0.2.3";
src = fetchFromGitHub {
owner = "igrr";
repo = "mkspiffs";
rev = version;
tag = finalAttrs.version;
fetchSubmodules = true;
hash = "sha256-oa6Lmo2yb66IjtEKkZyJBgM/p7rdvmrKfgNd2rAM/Lk=";
};
# 1) Fix build for Darwin
# 2) Fix cross
# 3) Do not run test as part of the buildPhase - the checkPhase will run it as `make test`
postPatch = ''
substituteInPlace Makefile \
--replace-fail "-arch i386 -arch x86_64" "" \
--replace-fail "strip" "${pkgsBuildHost.binutils.targetPrefix}strip" \
--replace-fail "dist: test" ""
'';
strictDeps = true;
buildFlags = [ "dist" ];
makeFlags = [
"VERSION=${version}"
"VERSION=${finalAttrs.version}"
"SPIFFS_VERSION=unknown"
];
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
installPhase = ''
mkdir -p $out/bin
cp mkspiffs $out/bin
install -Dm755 -t $out/bin mkspiffs
'';
meta = with lib; {
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
meta = {
description = "Tool to build and unpack SPIFFS images";
license = licenses.mit;
license = lib.licenses.mit;
homepage = "https://github.com/igrr/mkspiffs";
maintainers = with maintainers; [ haslersn ];
platforms = platforms.linux;
maintainers = [ lib.maintainers.haslersn ];
platforms = lib.platforms.all;
mainProgram = "mkspiffs";
};
}
})