I created a package tinymediamanager that builds a maven application.
After it got merged in nixpkgs i get a mvnHash missmatch.
Why did this happen?
How do i fix this for the future?
All maven plugin versions are pinned i tested it like it is described here: stable-maven-plugins with the maven-enforcer-plugin.
I tried debugging with gemini Ai and will describe what i already did to find out why the hash changed. (It wasn’t successful)
To test local changes to the package.nix file i have a flake.nix which allows me to simmulate aarch64.
flake.nix
{
description = "A flake for my custom package supporting multiple architectures";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
# Define the systems you want to support
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
# A helper function to generate outputs for each system
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
# Import nixpkgs specifically for the target system
pkgs = import nixpkgs { inherit system; };
});
in
{
# This defines your package for each supported system
packages = forAllSystems ({ pkgs }: {
default = pkgs.callPackage ./package.nix {};
});
# Optional: Provides a development shell (`nix develop`) for both architectures
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
inputsFrom = [ self.packages.${pkgs.system}.default ];
};
});
};
}
package.nix
{
alsa-lib,
autoPatchelfHook,
chromedriver,
copyDesktopItems,
deno,
ffmpeg,
fetchFromGitLab,
fontconfig,
glib,
gtk3,
imagemagick,
lib,
libmediainfo,
libx11,
libxext,
libxi,
libxrender,
libxtst,
libzen,
makeDesktopItem,
makeWrapper,
maven,
pipewire,
yt-dlp,
zenity,
zlib,
stdenv,
xz,
}:
let
sources = {
"x86_64-linux" = {
arch = "amd64";
binaryname = "tinyMediaManager";
};
"aarch64-linux" = {
arch = "arm64";
binaryname = "tinyMediaManager-arm";
};
};
sysSrc =
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
maven.buildMavenPackage rec {
pname = "tinyMediaManager";
version = "5.3.2";
mvnHash = "sha256-1JRA/5bXR/SpVpYBkqTT5RjQTNRzkhxgRoNSWr0O1fg=";
src = fetchFromGitLab {
owner = "tinyMediaManager";
repo = "tinyMediaManager";
tag = "tinyMediaManager-${version}";
hash = "sha256-t6QcETlKFkahEzE4oY2InKZkvo7YToaV02ZUCvqT0Uw=";
};
# remove other builds from pom.xml to speed up build
postPatch = ''
substituteInPlace pom.xml \
--replace-fail "<descriptor>src/assembly/windows-x64.xml</descriptor>" ""
'';
mvnDepsParameters = "-DskipTests -Pdist -DbuildNumber=${version} -Dmaven.buildNumber.skip=true";
mvnParameters = "-DskipTests -Pdist -DbuildNumber=${version} -Dmaven.buildNumber.skip=true";
nativeBuildInputs = [
autoPatchelfHook
copyDesktopItems
makeWrapper
imagemagick
xz
];
buildInputs = [
alsa-lib
glib
gtk3
libx11
libxext
libxi
libxrender
libxtst
zlib
];
strictDeps = true;
__structuredAttrs = true;
desktopItems = [
(makeDesktopItem {
name = "tinyMediaManager";
exec = "tinyMediaManager";
icon = "tinyMediaManager";
comment = "A media management tool";
desktopName = "tinyMediaManager";
genericName = "Media Manager";
categories = [
"Video"
"AudioVideo"
];
terminal = false;
})
];
installPhase = ''
runHook preInstall
# Create destination directory
mkdir -p $out/opt/tinyMediaManager $out/bin
tar -xvf "dist/tinyMediaManager-${version}-GIT-linux-${sysSrc.arch}.tar.gz" -C $out/opt/tinyMediaManager --strip-components=1
${lib.optionalString (
sysSrc.binaryname != "tinyMediaManager"
) "mv $out/opt/tinyMediaManager/${sysSrc.binaryname} $out/opt/tinyMediaManager/tinyMediaManager -n"}
makeWrapper $out/opt/tinyMediaManager/tinyMediaManager $out/bin/tinyMediaManager \
--prefix LD_LIBRARY_PATH : "${
lib.makeLibraryPath [
fontconfig
libmediainfo
libzen
pipewire
]
}" \
--prefix PATH : "${
lib.makeBinPath [
chromedriver
deno
ffmpeg
yt-dlp
zenity
]
}"
mkdir -p $out/share/pixmaps
ln -s $out/opt/tinyMediaManager/tmm.png $out/share/pixmaps/tinyMediaManager.png
for size in 16 32 48 64 128; do
mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
magick -background none $out/share/pixmaps/tinyMediaManager.png -resize "$size"x"$size" $out/share/icons/hicolor/"$size"x"$size"/apps/tinyMediaManager.png
done
# change startup settings to disable auto updates and use tools from PATH instead the shipped binaries
substituteInPlace $out/opt/tinyMediaManager/launcher.yml \
--replace-fail 'jvmOpts:' "jvmOpts:
- '-Dtmm.noupdate=true'
- '-Dtmm.useexternaltools=false'"
runHook postInstall
'';
meta = {
description = "Media management tool";
homepage = "https://www.tinymediamanager.org/";
changelog = "https://gitlab.com/tinyMediaManager/tinyMediaManager/-/releases/tinyMediaManager-${version}#changelog";
# the java code is open source but the binary which invokes the java code is unfree
# maven downloads this unfree binary
# the creator said that in the future it could be possible that building from source no longer works when he integrates stronger drm
# redistributing isn't allowed https://gitlab.com/tinyMediaManager/tinyMediaManager/-/work_items/3333
license =
with lib.licenses;
AND [
asl20
unfree
];
maintainers = with lib.maintainers; [ gamebeaker ];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
mainProgram = "tinyMediaManager";
};
}
I build the package with nix build .#packages.x86_64-linux.default or nix build .#packages.aarch64-linux.default
As the maven dependencies changed and i had an older successfull build still on my system i tried comparing the old maven dependencies against the new maven dependencies.
I changed the mvnHash to the old version that created the original mvnHash missmatch (The version that is currently in the nixpkgs store) and executed nix eval --raw .#packages.x86_64-linux.default.fetchedMavenDeps.outPath to get the store path to where the old maven dependencies got saved.
(old mvnHash = “sha256-1JRA/5bXR/SpVpYBkqTT5RjQTNRzkhxgRoNSWr0O1fg=”; )
$ nix eval --raw .#packages.x86_64-linux.default.fetchedMavenDeps.outPath
/nix/store/7vmamdvn8j7npq9h4zwjqh57fcamrhjk-maven-deps-tinyMediaManager-5.3.2
after that i changed the mvnHash to the new version and build it successfully. I got the store path in the same way.
(new mvnHash = “sha256-pLySrUiZz55ZpTn2JABtnFjoVa1iUlLN7oDeaIg9O8s=”; )
$ nix eval --raw .#packages.x86_64-linux.default.fetchedMavenDeps.outPath
/nix/store/iq61hakjpz0g89ir9m8hljk3xzq0l75i-maven-deps-tinyMediaManager-5.3.2
i packaged the maven dependencies with tar so other people can poke them and search for differences the command was:
tar -cvf archive.tar /nix/store/7vmamdvn8j7npq9h4zwjqh57fcamrhjk-maven-deps-tinyMediaManager-5.3.2 /nix/store/iq61hakjpz0g89ir9m8hljk3xzq0l75i-maven-deps-tinyMediaManager-5.3.2
(I write it so verbose as i think it has something to do with a metadata change during download and maybe tar striped these information, but i don’t know it so that a more knowledgable person can recognize it before wasting time)
Here is the download link: https://nextcloud.devomin.de/s/4retPctALbReyEQ
I compared the directories with nix hash path and couldn’t find a difference.
$ nix hash path /nix/store/7vmamdvn8j7npq9h4zwjqh57fcamrhjk-maven-deps-tinyMediaManager-5.3.2
sha256-pLySrUiZz55ZpTn2JABtnFjoVa1iUlLN7oDeaIg9O8s=
$ nix hash path /nix/store/iq61hakjpz0g89ir9m8hljk3xzq0l75i-maven-deps-tinyMediaManager-5.3.2
sha256-pLySrUiZz55ZpTn2JABtnFjoVa1iUlLN7oDeaIg9O8s=
The Ai tries to gaslight me that i simply had the wrong hash in package.nix from the beginning as nix hash path has the same result and i should just manually change the mvnHash to the new one.
Luckily nixpkgs-review exists and i always execute it after i made a force push in my PR. So i can see in my Comment that it build with the old mvnHash in the past.
I don’t know why the mvnHash changed, does anyone have any idea?