{ stdenv , lib , fetchFromGitHub , fetchurl , squashfsTools , xz }: let freetz = fetchFromGitHub { owner = "Freetz"; repo = "freetz"; rev = "e1358ac97af47d2b8faa7237a89b353724f573b7"; sha256 = "1k3l5n5hpzysj0n3fn1jazvrj89cxdf3bbz9jfzqccfi01vnhlsc"; }; in stdenv.mkDerivation rec { pname = "squashfs-avm-be"; version = "4.3"; src = fetchurl { url = "mirror://sourceforge/squashfs/squashfs${version}.tar.gz"; sha256 = "1xpklm0y43nd9i6jw43y2xh5zvlmj9ar2rvknh0bh7kv8c95aq0d"; }; prePatch = '' cd squashfs-tools ''; patches = [ "${freetz}/make/squashfs4-be/patches/001-de03266983ceb62e5365aac84fcd3b2fd4d16e6f.upstream.patch" "${freetz}/make/squashfs4-be/patches/002-4f24381e7edc0a46cf10278e4597051ac697ec7c.upstream.patch" "${freetz}/make/squashfs4-be/patches/010-fix_segfault_in_tracing_code.patch" "${freetz}/make/squashfs4-be/patches/050-freetz_specific_xz_paths.patch" "${freetz}/make/squashfs4-be/patches/060-link_compression_libs_statically.patch" "${freetz}/make/squashfs4-be/patches/100-TARGET_FORMAT.patch" "${freetz}/make/squashfs4-be/patches/101-TARGET_FORMAT__AVM_BE_AVM_LE_symbols_only.patch" "${freetz}/make/squashfs4-be/patches/200-help_comment_typos.patch" "${freetz}/make/squashfs4-be/patches/210-mksquashfs__uclibc_get_physical_memory.patch" "${freetz}/make/squashfs4-be/patches/220-mksquashfs__default_block_size.patch" "${freetz}/make/squashfs4-be/patches/230-mksquashfs__disable_xattrs_support.patch" "${freetz}/make/squashfs4-be/patches/240-mksquashfs__remove_append_mode_support.patch" "${freetz}/make/squashfs4-be/patches/250-mksquashfs__AVM_BE.patch" "${freetz}/make/squashfs4-be/patches/350-unsquashfs__AVM_BE.patch" "${freetz}/make/squashfs4-be/patches/400-unsquashfs123_lzma1_header_less.patch" "${freetz}/make/squashfs4-be/patches/410-unsquashfs123_optional.patch" "${freetz}/make/squashfs4-be/patches/450-unsquashfs__exit_on_error.patch" "${freetz}/make/squashfs4-be/patches/550-mkfs_time__AVM_BE_AVM_LE.patch" "${freetz}/make/squashfs4-be/patches/610-unsquashfs_superblock_offset.patch" "${freetz}/make/squashfs4-be/patches/611-unsquashfs_nmi_vector_gap.patch" "${freetz}/make/squashfs4-be/patches/612-ti_checksum.patch" "${freetz}/make/squashfs4-be/patches/900-sys_types__no__sys_sysmacros__include.patch" "${freetz}/make/squashfs4-be/patches/910-gcc10_fix_multiple_definitions_error.patch" ]; buildInputs = [ xz ]; NIX_LDFLAGS = "-lgcc_s"; preBuild = '' makeFlagsArray+=( EXTRA_CFLAGS="-DTARGET_FORMAT=AVM_BE -ffunction-sections -fdata-sections" GZIP_SUPPORT="0" LZMA_XZ_SUPPORT="0" XZ_SUPPORT="1" COMP_DEFAULT="xz" XATTR_SUPPORT="0" XATTR_DEFAULT="0" ) ''; installPhase = '' runHook preInstall mkdir -p $out/bin cp mksquashfs $out/bin/mksquashfs-avm-be cp unsquashfs $out/bin/unsquashfs-avm-be runHook postInstall ''; meta = { homepage = "http://squashfs.sourceforge.net/"; description = "Tool for creating and unpacking AVM FRITZ!Box firmware images"; platforms = lib.platforms.unix; license = lib.licenses.gpl2Plus; maintainers = with lib.maintainers; [ royneary ]; }; }