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

Problem compiling for NixOS #10

Open
quigonjeff opened this issue Aug 4, 2022 · 10 comments
Open

Problem compiling for NixOS #10

quigonjeff opened this issue Aug 4, 2022 · 10 comments

Comments

@quigonjeff
Copy link

Hi. I am having problems compiling for NixOS.
I am getting the following error messages:

error: failed to run custom build command for `nng-sys v1.4.0-rc.0`

Caused by:
  process didn't exit successfully: `/home/jefferson/workspace/firefox-profile-switcher-connector/target/release/build/nng-sys-cc321bf4e0b088b8/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=try_from
  CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
  CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
  CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-unknown-linux-gnu = None
  CMAKE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE = None
  CMAKE = None
  running: "cmake" "/home/jefferson/.cargo/registry/src/github.lhy31512.workers.dev-1ecc6299db9ec823/nng-sys-1.4.0-rc.0/nng" "-DNNG_TESTS=OFF" "-DNNG_TOOLS=OFF" "-DNNG_ENABLE_STATS=OFF" "-DNNG_ENABLE_TLS=OFF" "-DCMAKE_INSTALL_PREFIX=/home/jefferson/workspace/firefox-profile-switcher-connector/target/release/build/nng-sys-d6d52e806f81ce06/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/run/current-system/sw/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/run/current-system/sw/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/run/current-system/sw/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- Configuring for NNG version 1.4.0
  -- Building static libs.
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/jefferson/workspace/firefox-profile-switcher-connector/target/release/build/nng-sys-d6d52e806f81ce06/out/build
  running: "cmake" "--build" "." "--target" "install" "--config" "Release" "--parallel" "12"
  Consolidate compiler generated dependencies of target nng
  [  0%] Linking C static library libnng.a

  --- stderr
  make: warning: -j12 forced in submake: resetting jobserver mode.
  Error running link command: No such file or directory
  make[2]: *** [CMakeFiles/nng.dir/build.make:1426: libnng.a] Error 2
  make[1]: *** [CMakeFiles/Makefile2:723: CMakeFiles/nng.dir/all] Error 2
  make: *** [Makefile:156: all] Error 2
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 2

  build script failed, must exit now', /home/jefferson/.cargo/registry/src/github.lhy31512.workers.dev-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

Any advise on how to fix the problem?

Also, is there any chance you could provide an AppImage version of the connector?

Thanks a lot.

@epetousis
Copy link

epetousis commented Sep 6, 2022

How are you writing the derivation? I managed to get the extension compiling using the following:

{ lib, fetchFromGitHub, rustPlatform, cmake }:

rustPlatform.buildRustPackage rec {
  pname = "firefox-profile-switcher-connector";
  version = "0.1.1";

  src = fetchFromGitHub {
    owner = "null-dev";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-mnPpIJ+EQAjfjhrSSNTrvCqGbW0VMy8GHbLj39rR8r4=";
  };

  nativeBuildInputs = [ cmake ];

  cargoSha256 = "sha256-EQIBeZwF9peiwpgZNfMmjvLv8NyhvVGUjVXgkf12Wig=";

  postInstall = ''
  mkdir -p $out/lib/mozilla/native-messaging-hosts
  sed -i s#/usr/bin/ff-pswitch-connector#$out/bin/firefox_profile_switcher_connector# manifest/manifest-linux.json
  cp manifest/manifest-linux.json $out/lib/mozilla/native-messaging-hosts/ax.nd.profile_switcher_ff.json
  '';

  meta = with lib; {
    description = "Native connector software for the 'Profile Switcher for Firefox' extension.";
    homepage = "https://github.com/null-dev/firefox-profile-switcher-connector";
    license = licenses.gpl3;
  };
}

You can then add the extension as a messaging host to Firefox with something like:

{
  firefox = prev.firefox.override { extraNativeMessagingHosts = [ firefox-profile-switcher-connector ]; };
}

or:

{
  packages = with pkgs; [
    (firefox.override { extraNativeMessagingHosts = [ firefox-profile-switcher-connector ]; })
  ];
}

This seemed to compile for me just fine against nixpkgs-unstable. The only issue is I can't actually get the extension to switch profiles now...

@addy419
Copy link

addy419 commented Mar 13, 2023

@epetousis were you able to get it working?

Edit: Nevermind, got it working with #14 (comment)

@genebean
Copy link

Have any of you gotten this working in a way I could consume instead of writing my own thing? Relatedly, anyone submitted it to be in the default set of packages?

@addy419
Copy link

addy419 commented Sep 21, 2023

@genebean Yes, I got it working with @epetousis method and the link posted in my comment.

@genebean
Copy link

@addy419 is your package / code published somewhere that I can pull from or do I need to replicate what you have done? I am still fairly new to Nix so sorry if this sounds like a no duh question.

@addy419
Copy link

addy419 commented Sep 22, 2023

Hi @genebean you can check my config here https://github.com/addy419/configurations/blob/master/modules/desktop/firefox/firefox-profile-switcher-connector.nix and https://github.com/addy419/configurations/blob/master/modules/desktop/firefox/default.nix

Be sure to add the config file pointed in my comment once you are able to do this.

Edit: You can use the config on line 53 in my default.nix and set it automatically.

@genebean
Copy link

Many thanks @addy419

@genebean
Copy link

genebean commented Aug 5, 2024

I created a packaging request for Nix at NixOS/nixpkgs#332470 - it would be great if you all would +1 it if interested. Also, @epetousis if you are game to submit the package I'd be happy to try and help maintain it. I don't know enough about rust or nix packaging to be the sole maintainer, but am happy to help.

@epetousis
Copy link

epetousis commented Aug 5, 2024

Is that config hack still necessary to get the extension working? If it isn't I'll happily submit a PR, although it's been a while since I last used this.

@genebean
Copy link

genebean commented Aug 6, 2024

Is that config hack still necessary to get the extension working? If it isn't I'll happily submit a PR, although it's been a while since I last used this.

As far as I know, yes. It doesn't seem to be packaged in Nix anywhere.

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

No branches or pull requests

4 participants