Nix build: Error: invalid character in Base64 string: '

i’m packaging https://github.com/NixOS/nixpkgs/pull/154188

but
where’s this invalid character '?? (https://github.com/NixOS/nix/blob/fbd0a6c6e2e87f6679fe5cabaddaa877cf3e5a90/src/libutil/util.cc#L1573)

$ nix build --print-build-logs --show-trace /home/yuu/dev/nixpkgs#modelio
warning: Git tree '/home/yuu/dev/nixpkgs' is dirty
error: invalid character in Base64 string: '

hile evaluating the attribute 'buildPhase' of the derivation 'modelio-5.1.0'

       at /nix/store/11nyljykmm5bsn1y3zl6mqdcgn16p7pn-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

default.nix

{ lib
, javaPackages
, fetchFromGitHub
, fetchurl
, fetchpatch
, makeWrapper
, eclipse-sdk
, maven3
, openjdk8_headless
, atk
, cairo
, freetype
, gcc
, glib
, glibc
, gtk2
, jre8
, libXtst
, perl
, python
, swt
, webkitgtk
}:

let
  maven360 = maven3.overrideAttrs (oldAttrs: rec {
    _pname = "maven";
    pname = "apache-${_pname}";
    majorVersion = "3";
    version = "${majorVersion}.6.0";

    src = fetchurl {
      url = "https://archive.apache.org/dist/${_pname}/${_pname}-${majorVersion}/${version}/binaries/${pname}-${version}-bin.tar.gz";
      sha256 = "0ds61yy6hs7jgmld64b65ss6kpn5cwb186hw3i4il7vaydm386va";
    };

    jdk = openjdk8_headless;
  });
  maven = maven360;
in (javaPackages.mavenfod.override {
  inherit maven;
}) rec {
  pname = "modelio";
  version = "5.1.0";

  src = fetchFromGitHub {
    owner = "modelioopensource";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-+9dJuP+MzUZdzyjdjzgWNa5AyCv2U0Pz6v8MkBta4Gk=";
  };

  mvnSha256 = "sha256-6U1iDAcUMMQUH1FiYtoVhnU62rzZPqFkCZcZRpwqN8g=";
  # mvnParameters = "";

  patches = [
    # Fixes for building with Maven.
    # Error when building with Maven:
    # bin.includes value(s) [*/] do not match any files.
    # https://github.com/ModelioOpenSource/Modelio/issues/38
    (fetchpatch {
      name = "build-properties-remove-non-existent-directories-from-bin-includes.patch";
      url = "https://github.com/yuuyins/Modelio/commit/04fdda793f8ef191ff11ae9f633e07c052fc28bc.patch";
      sha256 = "sha256-S8KqfRtzf1fHi9gFyQiG3iHuhUxNyk0XcSqBnSCNsWs=";
    })
  ];

  nativeBuildInputs = [
    eclipse-sdk
    maven
    openjdk8_headless
  ];

  buildInputs = [
    atk # libatk
    cairo # libcairo
    freetype # libfreetype.so.6
    gcc # stdc++ 6
    glib # libglib2
    glibc # libc6
    gtk2 # libgtk2
    jre8 # java 8
    libXtst # libxtst6
    perl # plugins/**/bin/{antRun.pl,runant.pl,...}
    python # plugins/**/bin/{runant.py,...}
    swt #
    webkitgtk # libwebkitgtk-1.0
  ];

  JAVA_HOME = openjdk8_headless.home;
  LANG = "C.UTF-8";
  LC_ALL = "C.UTF-8";

  installPhase = ''
    runHook preInstall

    mkdir --parents $out/bin

    install -D --mode=644 \
      "$src/products/target/products/org.modelio.product/linux/gtk/x86_64/Modelio ${version}/*" \
      --target $out

    # ln --symbolic $out/usr/lib/modelio-open-source${version}/modelio $out/bin/modelio
    # ln --symbolic $out/usr/lib/modelio-open-source${version}/modelio.sh $out/bin/modelio.sh

    rm --recursive --force $out/usr/lib/modelio-open-source${version}/jre
    ln --symbolic ${jre8.home}/jre $out/usr/lib/modelio-open-source${version}/jre

    runHook postInstall
  '';

  meta = with lib; {
    description = "Free, extensible modeling environment for UML and BPMN";
    homepage = "https://www.modelio.org";
    changelog = "https://github.com/ModelioOpenSource/Modelio/releases";
    license = licenses.gpl3;
    platforms = platforms.all;
    maintainers = with maintainers; [ yuu ];
  };
}

maven-fod.nix (a bit modified from master)

{ lib
, stdenv
, maven
}:

{ src
, patches ? []
, pname
, version
, mvnSha256 ? "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
, mvnHash ? "sha256-${mvnSha256}"
, mvnFetchExtraArgs ? {}
, mvnParameters ? ""
, ...
} @args:

# originally extracted from dbeaver
# created to allow using maven packages in the same style as rust

stdenv.mkDerivation (rec {
  fetchedMavenDeps = stdenv.mkDerivation ({
    name = "${pname}-${version}-maven-deps";

    inherit src patches;

    buildInputs = [
      maven
    ];

    buildPhase = ''
      mvn clean package -Dmaven.repo.local=$out/.m2 ${mvnParameters}
    '';

    # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
    installPhase = ''
      find $out -type f \
        -name \*.lastUpdated -or \
        -name resolver-status.properties -or \
        -name _remote.repositories \
        -delete
    '';

    # don't do any fixup
    dontFixup = true;
    outputHashMode = "recursive";
    outputHash = mvnHash;
  } // mvnFetchExtraArgs);

  buildPhase = ''
    runHook preBuild

    mvnDeps=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)
    mvn clean package --offline "-Dmaven.repo.local=$mvnDeps/.m2" ${mvnParameters}

    runHook postBuild
  '';
} // args)

any help debugging this?

Those require two fundamentally different encodings. It’s not as simple as just appending the string; The nix command has some converters: nix hash

Alternatively, I think you should be able to use the SRI form (the one starting with sha256-) for both anyway, though I don’t know how maven-fod ends up using them.

1 Like

haha i was looking all strings below that one. thank you very much!! do you know if there is a specific reason nix can’t show the variable where the original problem was?

Heh, excellent question, and one someone working on nix itself can probably better answer.

In this case it shows you where the value ended up being used, I imagine it gets complex to trace this back to the original definition with all the indirection that happens in-between. Perhaps it’s just a question of needing more man power working on nix itself to clean this kind of thing up.

1 Like