Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lomiri.geonames: init at 0.3.0 #241259

Merged
merged 3 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/desktops/lomiri/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
#### Development tools / libraries
cmake-extras = callPackage ./development/cmake-extras { };
deviceinfo = callPackage ./development/deviceinfo { };
geonames = callPackage ./development/geonames { };
gmenuharness = callPackage ./development/gmenuharness { };
lomiri-api = callPackage ./development/lomiri-api { };
};
Expand Down
122 changes: 122 additions & 0 deletions pkgs/desktops/lomiri/development/geonames/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, gitUpdater
, testers
, buildPackages
, cmake
, docbook-xsl-nons
, docbook_xml_dtd_45
, gettext
, glib
, glibcLocales
, withExamples ? true
, gtk3
# Uses gtkdoc-scan* tools, which produces a binary linked against lib for hostPlatform and executes it to generate docs
, withDocumentation ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
, gtk-doc
, pkg-config
}:

stdenv.mkDerivation (finalAttrs: {
pname = "geonames";
version = "0.3.0";

src = fetchFromGitLab {
owner = "ubports";
repo = "development/core/geonames";
rev = finalAttrs.version;
hash = "sha256-Mo7Khj2pgdJ9kT3npFXnh1WTSsY/B1egWTccbAXFNY8=";
};

outputs = [
"out"
"dev"
] ++ lib.optionals withExamples [
"bin"
OPNA2608 marked this conversation as resolved.
Show resolved Hide resolved
] ++ lib.optionals withDocumentation [
"doc"
];

patches = [
# Improves install locations of demo & docs
# Remove when https://gitlab.com/ubports/development/core/geonames/-/merge_requests/3 merged & in release
(fetchpatch {
name = "0001-geonames-Use-GNUInstallDirs-more.patch";
url = "https://gitlab.com/OPNA2608/geonames/-/commit/e64a391fc213b2629da1c8bbf975fd62a2973c51.patch";
hash = "sha256-HPYDtIy1WUrZLPzvKh4aezrT/LniZkNX+PeQ9YB85RY=";
})
];

postPatch = ''
patchShebangs src/generate-locales.sh tests/setup-test-env.sh
'';

strictDeps = true;

nativeBuildInputs = [
cmake
gettext
glib # glib-compile-resources
pkg-config
] ++ lib.optionals withDocumentation [
docbook-xsl-nons
docbook_xml_dtd_45
gtk-doc
];

buildInputs = [
glib
] ++ lib.optionals withExamples [
gtk3
];

# Tests need to be able to check locale
LC_ALL = lib.optionalString finalAttrs.doCheck "en_US.UTF-8";
nativeCheckInputs = [
glibcLocales
];

makeFlags = [
# gtkdoc-scan runs ld, can't find qsort & strncpy symbols
"LD=${stdenv.cc.targetPrefix}cc"
];

cmakeFlags = [
"-DWANT_DOC=${lib.boolToString withDocumentation}"
"-DWANT_DEMO=${lib.boolToString withExamples}"
"-DWANT_TESTS=${lib.boolToString finalAttrs.doCheck}"
# Keeps finding & using glib-compile-resources from buildInputs otherwise
"-DCMAKE_PROGRAM_PATH=${lib.makeBinPath [ buildPackages.glib.dev ]}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have added glib to nativeBuildInputs, Setting CMAKE_PROGRAM_PATH here may no longer be necessary

Copy link
Contributor Author

@OPNA2608 OPNA2608 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, it still picks up the one from buildInputs instead of nativeBuildInputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--argstr crossSystem riscv64-linux with this line removed:

[ 41%] Generating geonames-resources.c
/nix/store/51sszqz1d9kpx480scb1vllc00kxlx79-bash-5.2-p15/bin/bash: line 1: /nix/store/76cd2vr6rsp3fzwlrpaq6n8phdklnvq0-glib-riscv64-unknown-linux-gnu-2.76.3-dev/bin/glib-compile-resources: cannot execute binary file: Exec format error
make[2]: *** [src/CMakeFiles/geonames.dir/build.make:74: src/geonames-resources.c] Error 126

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test nix-build -A pkgsCross.riscv64.lomiri.geonames , It should be built successfully without CMAKE_PROGRAM_PATH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not, same error.

[ 41%] Generating geonames-resources.c
/nix/store/51sszqz1d9kpx480scb1vllc00kxlx79-bash-5.2-p15/bin/bash: line 1: /nix/store/76cd2vr6rsp3fzwlrpaq6n8phdklnvq0-glib-riscv64-unknown-linux-gnu-2.76.3-dev/bin/glib-compile-resources: cannot execute binary file: Exec format error
make[2]: *** [src/CMakeFiles/geonames.dir/build.make:74: src/geonames-resources.c] Error 126
make[1]: *** [CMakeFiles/Makefile2:199: src/CMakeFiles/geonames.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
error: builder for '/nix/store/vccsfh93aaznxm0q30y4q6vjld7qa4nh-geonames-riscv64-unknown-linux-gnu-0.3.0.drv' failed with exit code 2;

Copy link
Member

@wineee wineee Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nix-shell:~/.cache/nixpkgs-review/pr-241259/nixpkgs]$ git diff

pkgs/desktops/lomiri/development/geonames/default.nix
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

───────────────────────────────────────┐
85: stdenv.mkDerivation (finalAttrs: { │
───────────────────────────────────────┘
    "-DWANT_DEMO=${lib.boolToString withExamples}"
    "-DWANT_TESTS=${lib.boolToString finalAttrs.doCheck}"
    # Keeps finding & using glib-compile-resources from buildInputs otherwise
    "-DCMAKE_PROGRAM_PATH=${lib.makeBinPath [ buildPackages.glib.dev ]}"
    #"-DCMAKE_PROGRAM_PATH=${lib.makeBinPath [ buildPackages.glib.dev ]}"
  ];

  preInstall = lib.optionalString withDocumentation ''

[nix-shell:~/.cache/nixpkgs-review/pr-241259/nixpkgs]$ nix-build -A lomiri.geonames --argstr crossSystem riscv64-linux
/nix/store/3m45psnzk57q55zy8xgwd2q449a4jahq-geonames-riscv64-unknown-linux-gnu-0.3.0

Unable to reproduce build failure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird.

[ 25%] Built target generated-files
[ 33%] Generating locales-gen
[ 33%] Built target localesgen
[ 41%] Generating geonames-resources.c
/nix/store/51sszqz1d9kpx480scb1vllc00kxlx79-bash-5.2-p15/bin/bash: line 1: /nix/store/76cd2vr6rsp3fzwlrpaq6n8phdklnvq0-glib-riscv64-unknown-linux-gnu-2.76.3-dev/bin/glib-compile-resources: cannot execute binary file: Exec format error
make[2]: *** [src/CMakeFiles/geonames.dir/build.make:74: src/geonames-resources.c] Error 126
make[1]: *** [CMakeFiles/Makefile2:199: src/CMakeFiles/geonames.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
error: builder for '/nix/store/vccsfh93aaznxm0q30y4q6vjld7qa4nh-geonames-riscv64-unknown-linux-gnu-0.3.0.drv' failed with exit code 2;
       last 10 log lines:
       > /build/source/data/alternatenames/GS.txt
       > /build/source/data/alternatenames/GT.txt
       > [ 25%] Built target generated-files
       > [ 33%] Generating locales-gen
       > [ 33%] Built target localesgen
       > [ 41%] Generating geonames-resources.c
       > /nix/store/51sszqz1d9kpx480scb1vllc00kxlx79-bash-5.2-p15/bin/bash: line 1: /nix/store/76cd2vr6rsp3fzwlrpaq6n8phdklnvq0-glib-riscv64-unknown-linux-gnu-2.76.3-dev/bin/glib-compile-resources: cannot execute binary file: Exec format error
       > make[2]: *** [src/CMakeFiles/geonames.dir/build.make:74: src/geonames-resources.c] Error 126
       > make[1]: *** [CMakeFiles/Makefile2:199: src/CMakeFiles/geonames.dir/all] Error 2
       > make: *** [Makefile:136: all] Error 2
       For full logs, run 'nix log /nix/store/vccsfh93aaznxm0q30y4q6vjld7qa4nh-geonames-riscv64-unknown-linux-gnu-0.3.0.drv'.

[nix-shell:~/.cache/nixpkgs-review/pr-241259/nixpkgs]$ git diff
diff --git a/pkgs/desktops/lomiri/development/geonames/default.nix b/pkgs/desktops/lomiri/development/geonames/default.nix
index c4e327caf93..3532916a50c 100644
--- a/pkgs/desktops/lomiri/development/geonames/default.nix
+++ b/pkgs/desktops/lomiri/development/geonames/default.nix
@@ -86,7 +86,7 @@ stdenv.mkDerivation (finalAttrs: {
     "-DWANT_DEMO=${lib.boolToString withExamples}"
     "-DWANT_TESTS=${lib.boolToString finalAttrs.doCheck}"
     # Keeps finding & using glib-compile-resources from buildInputs otherwise
-    "-DCMAKE_PROGRAM_PATH=${lib.makeBinPath [ buildPackages.glib.dev ]}"
+    #"-DCMAKE_PROGRAM_PATH=${lib.makeBinPath [ buildPackages.glib.dev ]}"
   ];
 
   preInstall = lib.optionalString withDocumentation ''

Copy link
Contributor Author

@OPNA2608 OPNA2608 Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you maybe have riscv64-linux in your boot.binfmt.emulatedSystems so you can execute risc-v binaries on your system? I think that would cause it to "work".

Warning: the builder can execute all emulated systems within the same build, which introduces impurities in the case of cross compilation.

I have aarch64-linux in mine, and cross-compiling for that likely "works" without CMAKE_PROGRAM_PATH because of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that makes sense

] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
# only for cross without native execute support because the canExecute "emulator" call has a format that I can't get CMake to accept
"-DCMAKE_CROSSCOMPILING_EMULATOR=${stdenv.hostPlatform.emulator buildPackages}"
];

preInstall = lib.optionalString withDocumentation ''
# gtkdoc-mkhtml generates images without write permissions, errors out during install
chmod +w doc/reference/html/*
'';

doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

passthru = {
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
updateScript = gitUpdater { };
};

meta = with lib; {
description = "Parse and query the geonames database dump";
homepage = "https://gitlab.com/ubports/development/core/geonames";
license = licenses.gpl3Only;
maintainers = teams.lomiri.members;
platforms = platforms.all;
# Cross requires hostPlatform emulation during build
# https://gitlab.com/ubports/development/core/geonames/-/issues/1
broken = stdenv.buildPlatform != stdenv.hostPlatform && !stdenv.hostPlatform.emulatorAvailable buildPackages;
OPNA2608 marked this conversation as resolved.
Show resolved Hide resolved
pkgConfigModules = [
"geonames"
];
};
})