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

meta: add nix flake to build on Linux #12

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vincenzopalazzo
Copy link

@vincenzopalazzo vincenzopalazzo commented Mar 25, 2024

As noted in [1] on Linux systems, it is not possible to build phoenixd due to a mismatch in the libc version.

A possible solution is to use Nix and build phoenixd inside the shell with all the dependencies. This way, the host machine can use the binary directly without downgrading libc, which can be dangerous.

[1] #1 (comment)

@vincenzopalazzo vincenzopalazzo marked this pull request as ready for review March 26, 2024 00:01
@tsmith123
Copy link

Is this linked to an error I'm receiving when trying to build on Fedora 39?

"./phoenixd: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory"

@pm47
Copy link
Member

pm47 commented Mar 27, 2024

Is this linked to an error I'm receiving when trying to build on Fedora 39?
"./phoenixd: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory"

It's unrelated, you need something like sudo yum install libxcrypt-compat

@pm47
Copy link
Member

pm47 commented Mar 27, 2024

I'm getting a JVM crash at build, starting from docker run -ti ghcr.io/nixos/nix.

@vincenzopalazzo
Copy link
Author

I'm getting a JVM crash at build, starting from docker run -ti ghcr.io/nixos/nix.

Interesting @pm47 I will try to reproduce it today with your setting and get back to you, thanks for testing this PR our

@vincenzopalazzo
Copy link
Author

Ok I was able to reproduce by passing the --pure flag

This is the stack trace and currently, I do not have a solution :/ there is someone with ideas?

[nix-shell:~/github/phoenixd]$ ./gradlew packageLinuxX64 --no-daemon
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.5/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
> Task :buildSrc:checkKotlinGradlePluginConfigurationErrors
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources NO-SOURCE
> Task :buildSrc:compileKotlin
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:classes UP-TO-DATE

> Task :buildSrc:jar
:jar: No valid plugin descriptors were found in META-INF/gradle-plugins

> Task :buildVersionsTask
> Task :checkKotlinGradlePluginConfigurationErrors
> Task :xcodeVersion SKIPPED
> Task :generateCommonMainPhoenixDatabaseInterface
> Task :compileKotlinLinuxX64
The message received from the daemon indicates that the daemon has disappeared.
Build request sent: Build{id=af03fa4c-629f-4970-86ed-8543359d0249, currentDir=/home/vincenzopalazzo/github/phoenixd}
Attempting to read last messages from the daemon log...
Daemon pid: 143699
  log file: /home/vincenzopalazzo/.gradle/daemon/8.5/daemon-143699.out.log
----- Last  20 lines from daemon log file - daemon-143699.out.log -----
2024-03-28T18:19:36.753+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Command execution: started DaemonCommandExecution[command = Build{id=af03fa4c-629f-4970-86ed-8543359d0249, currentDir=/home/vincenzopalazzo/github/phoenixd}, connection = DefaultDaemonConnection: socket connection from /127.0.0.1:35799 to /127.0.0.1:48384] after 0.0 minutes of idle
2024-03-28T18:19:36.753+0100 [INFO] [org.gradle.launcher.daemon.server.DaemonRegistryUpdater] Marking the daemon as busy, address: [c7681f46-0ad6-4543-b1ec-5b2545f10cac port:35799, addresses:[localhost/127.0.0.1]]
2024-03-28T18:19:36.754+0100 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Marking busy by address: [c7681f46-0ad6-4543-b1ec-5b2545f10cac port:35799, addresses:[localhost/127.0.0.1]]
2024-03-28T18:19:36.754+0100 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry.
2024-03-28T18:19:36.755+0100 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2024-03-28T18:19:36.755+0100 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2024-03-28T18:19:36.755+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] resetting idle timer
2024-03-28T18:19:36.756+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] daemon is running. Sleeping until state changes.
2024-03-28T18:19:36.756+0100 [INFO] [org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy] Daemon is about to start building Build{id=af03fa4c-629f-4970-86ed-8543359d0249, currentDir=/home/vincenzopalazzo/github/phoenixd}. Dispatching build started information...
2024-03-28T18:19:36.756+0100 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 34: dispatching org.gradle.launcher.daemon.protocol.BuildStarted@48b9969b
2024-03-28T18:19:36.757+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment] Configuring env variables: [PATH, depsBuildTarget, buildInputs, NIXPKGS_CONFIG, doCheck, LESSKEYIN_SYSTEM, NIX_PROFILES, DBUS_SESSION_BUS_ADDRESS, ANDROID_HOME, OBJCOPY, NIX_USER_PROFILE_DIR, READELF, depsHostHostPropagated, LC_PAPER, nativeBuildInputs, PWD, NIX_BUILD_TOP, shellHook, LESSOPEN, stdenv, PAGER, patches, SIZE, ZSH, IN_NIX_SHELL, LIBEXEC_PATH, AR, AS, system, ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE, SHLVL, QT_PLUGIN_PATH, STRIP, TERMINAL, NIX_ENFORCE_NO_NATIVE, HOST_PATH, JAVA_HOME, TERM, cmakeFlags, XDG_CONFIG_DIRS, propagatedBuildInputs, XDG_DESKTOP_PORTAL_DIR, depsTargetTarget, XDG_SESSION_ID, out, QTWEBKIT_PLUGIN_PATH, QT_STYLE_OVERRIDE, PKG_CONFIG_PATH_FOR_TARGET, builder, NIX_PKG_CONFIG_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu, phases, LC_NAME, XDG_SESSION_CLASS, NIX_GSETTINGS_OVERRIDES_DIR, CC, ZSH_2000_DISABLE_RIGHT_PROMPT, QML2_IMPORT_PATH, LOCALE_ARCHIVE, SSH_TTY, SSH_CLIENT, propagatedNativeBuildInputs, SSH_CONNECTION, LD, NIX_HARDENING_ENABLE, NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu, __NIXOS_SET_ENVIRONMENT_DONE, outputs, LC_MEASUREMENT, CXX, LC_TELEPHONE, XCURSOR_PATH, XDG_DATA_DIRS, LC_TIME, GIO_EXTRA_MODULES, strictDeps, OBJDUMP, LOGNAME, GTK_PATH, INFOPATH, depsTargetTargetPropagated, RANLIB, SHELL, LC_ADDRESS, doInstallCheck, NIX_CC, GOPATH, OLDPWD, mesonFlags, TMPDIR, buildPhase, SSH_ASKPASS, TEMPDIR, shell, ZSH_2000_DEFAULT_USER, __ETC_PROFILE_DONE, name, NIX_BINTOOLS, LESS, NIX_LDFLAGS, __structuredAttrs, LS_COLORS, depsBuildTargetPropagated, depsHostHost, NM, LC_IDENTIFICATION, STRINGS, LC_MONETARY, DOCKER_HOST, NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu, configureFlags, CUPS_DATADIR, LANG, XDG_SESSION_TYPE, PKG_CONFIG_FOR_TARGET, CONFIG_SHELL, SOURCE_DATE_EPOCH, LSCOLORS, NIX_CFLAGS_COMPILE, NIX_PATH, preferLocalBuild, GPG_TTY, depsBuildBuildPropagated, USER, TZDIR, LC_NUMERIC, EDITOR, TEMP, TMP, NIX_STORE, QT_QPA_PLATFORMTHEME, XDG_RUNTIME_DIR, depsBuildBuild, TERMINFO_DIRS, HOME, NIX_BUILD_CORES]
2024-03-28T18:19:36.762+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.LogToClient] About to start relaying all logs to the client via the connection.
2024-03-28T18:19:36.762+0100 [INFO] [org.gradle.launcher.daemon.server.exec.LogToClient] The client will now receive all logging from the daemon (pid: 143699). The daemon log file: /home/vincenzopalazzo/.gradle/daemon/8.5/daemon-143699.out.log
2024-03-28T18:19:36.764+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon] Requesting daemon stop after processing Build{id=af03fa4c-629f-4970-86ed-8543359d0249, currentDir=/home/vincenzopalazzo/github/phoenixd}
2024-03-28T18:19:36.764+0100 [LIFECYCLE] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Daemon will be stopped at the end of the build
2024-03-28T18:19:36.764+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Stop as soon as idle requested. The daemon is busy: true
2024-03-28T18:19:36.764+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] daemon stop has been requested. Sleeping until state changes.
2024-03-28T18:19:36.765+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has started executing the build.
2024-03-28T18:19:36.765+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] Executing build with daemon context: DefaultDaemonContext[uid=1295d147-e358-4f80-9033-57de70056b50,javaHome=/nix/store/d3sziy6zr4hk77vz7lp8qzr0bqmsfjh4-openjdk-20+36/lib/openjdk,daemonRegistryDir=/home/vincenzopalazzo/.gradle/daemon,pid=143699,idleTimeout=120000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
:jar: No valid plugin descriptors were found in META-INF/gradle-plugins
----- End of the daemon log -----

JVM crash log found: file:///home/vincenzopalazzo/github/phoenixd/hs_err_pid143699.log

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
> Task :linkPhoenix-cliDebugExecutableLinuxX64

@vincenzopalazzo vincenzopalazzo marked this pull request as draft March 28, 2024 17:23
@prusnak
Copy link

prusnak commented Apr 11, 2024

Clean solution would be to add flake.nix file to the repo which builds from source.

This proposal is very hackish :-)

@vincenzopalazzo
Copy link
Author

Hi @prusnak,

This proposal is very hackish :-)

haha I am a really convoluted nix user, but if you have time to review it we I can spend some time resurrecting it and maybe build a nix package too

@prusnak
Copy link

prusnak commented Apr 12, 2024

but if you have time to review

I will happily review and merge package submission to nixos/nixpkgs and/or flake.nix inclusion in this repo.

@vincenzopalazzo vincenzopalazzo force-pushed the macros/nix-shell branch 2 times, most recently from ae98bdd to e7e3e6e Compare November 7, 2024 09:16
@vincenzopalazzo vincenzopalazzo changed the title meta: add nix shell to build on Linux meta: add nix flake to build on Linux Nov 7, 2024
@vincenzopalazzo
Copy link
Author

I push some code @prusnak but I think it is missing the glibc=2.19, I think would be good to have your review on my initial flake version :)

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@vincenzopalazzo vincenzopalazzo force-pushed the macros/nix-shell branch 2 times, most recently from 2f69339 to f05f916 Compare November 7, 2024 17:41
As noted in [1] on Linux systems, it is not possible to build phoenixd due to a mismatch in the libc version.

A possible solution is to use Nix and build phoenixd inside the shell with all the dependencies. This way, the host machine can use the binary directly without downgrading libc, which can be dangerous.

[1] ACINQ#1 (comment)
Co-authored-by: Pavol Rusnak <[email protected]>
Signed-off-by: Vincenzo Palazzo <[email protected]>
Signed-off-by: Vincenzo Palazzo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants