firefox-profile-switcher-connector
firefox-profile-switcher-connector copied to clipboard
Problem compiling for NixOS
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.com-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.com-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.
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...
@epetousis were you able to get it working?
Edit: Nevermind, got it working with https://github.com/null-dev/firefox-profile-switcher-connector/issues/14#issuecomment-1366879583
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?
@genebean Yes, I got it working with @epetousis method and the link posted in my comment.
@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.
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.
Many thanks @addy419
I created a packaging request for Nix at https://github.com/NixOS/nixpkgs/issues/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.
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.
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.