Packaging Rust app for Nix fails

Hello, I run into compilation issues when packaging the Nostr client Gossip despite being able to install it in a nix-shell without issue.

I am building with nix-env -f $(pwd) -i gossip The package also requires rustc >= 1.65 which is why I am using rust-bin.beta.latest.default
Any help would be appreciated.

with import <nixpkgs> {
  
  overlays = [
    (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
  ];
};

rustPlatform.buildRustPackage rec {
  pname = "gossip";
  version = "0.4.2";
 
nativeBuildInputs = [
    pkg-config
    openssl
    fontconfig
    rust-bin.beta.latest.default
];

src = fetchFromGitHub {
  owner = "mikedilger";
  repo = "gossip";
  rev = "v0.4.2";
  sha256 = "Qr8XXXdIyVjPhu+bmeMlxQpfxtUKBgP94HonSQzryro=";
};

cargoSha256 = "2DsAWg9hrYCX4MHeR1O95vKMxeY3dgK80XecndGoHPY=";


postInstall = ''
                mkdir -p $out/share/applications/
                cp packaging/debian/gossip.desktop $out/share/applications/
                cp target/release/gossip $out/bin/
              '';

meta = with lib; {
  description = "Gossip is a nostr client.";
  homepage = "https://github.com/mikedilger/gossip";
  license = licenses.mit;
  maintainers = with maintainers; [jasonodoom];
  };
}

I would start by saying nix-env is deprecated/problematic. But I will investigate this not now.

1 Like

Hello, just checking in. Are there any updates?

What exactly are the issues you have?

I am getting some compilation errors when packaging but locally I am able to build with all dependencies without issue.

λ nix-build
this derivation will be built:
  /nix/store/1h8zjbwb57z23rsdnrhdhhm18dd50vxn-gossip-0.5.2.drv
building '/nix/store/1h8zjbwb57z23rsdnrhdhhm18dd50vxn-gossip-0.5.2.drv'...
unpacking sources
unpacking source archive /nix/store/xqw2ba2xw10c0mp813j3ai3dzgy8rsvz-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/f5zr3mmdiqvgikcd75nda2g8icdfda06-gossip-0.5.2-vendor.tar.gz
Finished cargoSetupPostUnpackHook
patching sources
Executing cargoSetupPostPatchHook
Validating consistency between /build/source/Cargo.lock and /build/gossip-0.5.2-vendor.tar.gz/Cargo.lock
Finished cargoSetupPostPatchHook
configuring
building
Executing cargoBuildHook
++ env CC_x86_64-unknown-linux-gnu=/nix/store/9nj6qjqp0d25giirzj9f0k35g2s58g0h-gcc-wrapper-11.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/9nj6qjqp0d25giirzj9f0k35g2s58g0h-gcc-wrapper-11.3.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/9nj6qjqp0d25giirzj9f0k35g2s58g0h-gcc-wrapper-11.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/9nj6qjqp0d25giirzj9f0k35g2s58g0h-gcc-wrapper-11.3.0/bin/c++ cargo build -j 24 --target x86_64-unknown-linux-gnu --frozen --release
   Compiling libc v0.2.140
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.51
   Compiling quote v1.0.23
   Compiling unicode-ident v1.0.8
   Compiling syn v1.0.109
   Compiling version_check v0.9.4
   Compiling once_cell v1.17.1
   Compiling memchr v2.5.0
   Compiling typenum v1.16.0
   Compiling futures-core v0.3.27
   Compiling log v0.4.17
   Compiling zeroize v1.5.7
   Compiling smallvec v1.10.0
   Compiling serde_derive v1.0.155
   Compiling scopeguard v1.1.0
   Compiling bitflags v1.3.2
   Compiling pin-project-lite v0.2.9
   Compiling subtle v2.4.1
   Compiling xml-rs v0.8.4
   Compiling pkg-config v0.3.26
   Compiling serde v1.0.155
   Compiling crossbeam-utils v0.8.15
   Compiling parking_lot_core v0.9.7
   Compiling futures-sink v0.3.27
   Compiling futures-task v0.3.27
   Compiling thiserror v1.0.39
   Compiling futures-io v0.3.27
   Compiling adler v1.0.2
   Compiling crc32fast v1.3.2
   Compiling tracing-core v0.1.30
   Compiling miniz_oxide v0.6.2
   Compiling generic-array v0.14.6
   Compiling lock_api v0.4.9
   Compiling slab v0.4.8
   Compiling indexmap v1.9.2
   Compiling memoffset v0.6.5
   Compiling cpufeatures v0.2.5
   Compiling ahash v0.7.6
   Compiling lazy_static v1.4.0
   Compiling cc v1.0.79
   Compiling futures-channel v0.3.27
   Compiling hashbrown v0.12.3
   Compiling pin-utils v0.1.0
   Compiling futures-util v0.3.27
   Compiling winnow v0.3.5
   Compiling toml_datetime v0.6.1
   Compiling libloading v0.7.4
   Compiling flate2 v1.0.25
   Compiling byteorder v1.4.3
   Compiling memoffset v0.7.1
   Compiling dlib v0.5.0
   Compiling polling v2.6.0
   Compiling wayland-sys v0.29.5
   Compiling itoa v1.0.6
   Compiling event-listener v2.5.3
   Compiling wayland-scanner v0.29.5
   Compiling bytes v1.4.0
   Compiling percent-encoding v2.2.0
   Compiling async-fs v1.6.0
   Compiling async-io v1.12.0
   Compiling ppv-lite86 v0.2.17
   Compiling concurrent-queue v2.1.0
   Compiling tokio v1.26.0
   Compiling memoffset v0.8.0
   Compiling parking v2.0.0
   Compiling tinyvec_macros v0.1.1
   Compiling waker-fn v1.1.0
   Compiling fastrand v1.9.0
   Compiling untrusted v0.7.1
   Compiling ttf-parser v0.18.1
   Compiling float-cmp v0.9.0
   Compiling base64 v0.13.1
   Compiling cfg_aliases v0.1.1
   Compiling async-trait v0.1.66
   Compiling khronos_api v3.1.0
   Compiling spin v0.5.2
   Compiling ring v0.16.20
   Compiling futures-lite v1.12.0
   Compiling strict-num v0.1.0
   Compiling tinyvec v1.6.0
   Compiling async-lock v2.7.0
   Compiling png v0.17.7
   Compiling aho-corasick v0.7.20
   Compiling crossbeam-epoch v0.9.14
   Compiling getrandom v0.2.8
   Compiling socket2 v0.4.9
   Compiling num_cpus v1.15.0
   Compiling mio v0.8.6
   Compiling nix v0.24.3
   Compiling rand_core v0.6.4
   Compiling block-buffer v0.10.4
   Compiling parking_lot v0.12.1
   Compiling crypto-common v0.1.6
   Compiling rand_chacha v0.3.1
   Compiling signal-hook-registry v1.4.1
   Compiling digest v0.10.6
   Compiling slotmap v1.0.6
   Compiling wayland-client v0.29.5
   Compiling ab_glyph_rasterizer v0.1.8
   Compiling minimal-lexical v0.2.1
   Compiling rand v0.8.5
   Compiling sha1 v0.10.5
   Compiling scoped-tls v1.0.1
   Compiling regex-syntax v0.6.28
   Compiling arrayvec v0.7.2
   Compiling downcast-rs v1.2.0
   Compiling nom v7.1.3
   Compiling unicode-normalization v0.1.22
   Compiling wayland-protocols v0.29.5
   Compiling block-padding v0.3.2
   Compiling form_urlencoded v1.1.0
   Compiling toml_edit v0.19.5
   Compiling unicode-bidi v0.3.11
   Compiling fnv v1.0.7
   Compiling async-task v4.3.0
   Compiling static_assertions v1.1.0
   Compiling arrayref v0.3.6
   Compiling http v0.2.9
   Compiling inout v0.1.3
   Compiling gl_generator v0.14.0
   Compiling hmac v0.12.1
   Compiling nix v0.25.1
   Compiling dirs-sys v0.3.7
   Compiling async-channel v1.8.0
   Compiling owned_ttf_parser v0.18.1
   Compiling idna v0.3.0
   Compiling ab_glyph v0.2.20
   Compiling smithay-client-toolkit v0.16.0
   Compiling x11-dl v2.21.0
   Compiling num-traits v0.2.15
   Compiling httparse v1.8.0
   Compiling rayon-core v1.11.0
   Compiling const-oid v0.9.2
   Compiling hex v0.4.3
   Compiling atomic-waker v1.1.0
   Compiling rustls v0.20.8
   Compiling vec_map v0.8.2
   Compiling blocking v1.3.0
   Compiling der v0.7.1
   Compiling url v2.3.1
   Compiling dirs v4.0.0
   Compiling crossbeam-deque v0.8.3
   Compiling proc-macro-crate v1.3.1
   Compiling cipher v0.4.4
   Compiling memmap2 v0.5.10
   Compiling regex v1.7.1
   Compiling crossbeam-channel v0.5.7
   Compiling xcursor v0.3.4
   Compiling num-integer v0.1.45
   Compiling ahash v0.8.3
   Compiling nix v0.26.2
   Compiling zvariant_utils v1.0.0
   Compiling wayland-commons v0.29.5
   Compiling async-executor v1.5.0
   Compiling async-broadcast v0.5.1
   Compiling ordered-stream v0.2.0
   Compiling alloc-no-stdlib v2.0.4
   Compiling alloc-stdlib v0.2.2
   Compiling spki v0.7.0
   Compiling winit v0.28.2
   Compiling ff v0.13.0
   Compiling serde_json v1.0.94
   Compiling base16ct v0.2.0
   Compiling ryu v1.0.13
   Compiling nohash-hasher v0.2.0
   Compiling either v1.8.1
   Compiling raw-window-handle v0.5.1
   Compiling try-lock v0.2.4
   Compiling rayon v1.7.0
   Compiling want v0.3.0
   Compiling sec1 v0.7.1
   Compiling wayland-cursor v0.29.5
   Compiling group v0.13.0
   Compiling pkcs8 v0.10.1
   Compiling brotli-decompressor v2.3.4
   Compiling glutin_egl_sys v0.4.0
   Compiling glutin_glx_sys v0.4.0
   Compiling http-body v0.4.5
   Compiling hkdf v0.12.3
   Compiling sha2 v0.10.6
   Compiling crypto-bigint v0.5.0
   Compiling nanorand v0.7.0
   Compiling spin v0.9.5
   Compiling wayland-sys v0.30.1
   Compiling num-rational v0.4.1
   Compiling instant v0.1.12
   Compiling httpdate v1.0.2
   Compiling tower-service v0.3.2
   Compiling base64ct v1.6.0
   Compiling simd-adler32 v0.3.4
   Compiling weezl v0.1.7
   Compiling x11rb-protocol v0.10.0
   Compiling rfc6979 v0.4.0
   Compiling webpki v0.22.0
   Compiling sct v0.7.0
   Compiling password-hash v0.5.0
   Compiling brotli v3.3.4
   Compiling webpki-roots v0.22.6
   Compiling elliptic-curve v0.13.2
   Compiling tracing-attributes v0.1.23
   Compiling thiserror-impl v1.0.39
   Compiling bytemuck_derive v1.4.0
   Compiling futures-macro v0.3.27
   Compiling enumflags2_derive v0.7.4
   Compiling zvariant_derive v3.12.0
   Compiling tokio-macros v1.8.2
   Compiling derivative v2.2.0
   Compiling async-recursion v1.0.2
   Compiling zbus_macros v3.11.0
   Compiling serde_repr v0.1.11
   Compiling enumn v0.1.7
   Compiling pin-project-internal v1.0.12
   Compiling jpeg-decoder v0.3.0
   Compiling bytemuck v1.13.1
   Compiling zune-inflate v0.2.51
   Compiling tiny-skia-path v0.8.3
   Compiling signature v2.0.0
   Compiling calloop v0.10.5
   Compiling universal-hash v0.5.0
   Compiling gethostname v0.2.3
   Compiling tiny-skia v0.8.3
   Compiling tracing v0.1.37
   Compiling glutin v0.30.6
   Compiling bit_field v0.10.2
   Compiling base64 v0.21.0
   Compiling lebe v0.5.2
   Compiling utf-8 v0.7.6
   Compiling color_quant v1.1.0
   Compiling half v2.2.1
   Compiling siphasher v0.3.10
   Compiling vcpkg v0.2.15
   Compiling pin-project v1.0.12
   Compiling flume v0.10.14
   Compiling opaque-debug v0.3.0
   Compiling dlv-list v0.3.0
   Compiling xmlparser v0.13.5
   Compiling poly1305 v0.8.0
   Compiling svgtypes v0.8.2
   Compiling roxmltree v0.15.1
   Compiling sctk-adwaita v0.5.3
   Compiling exr v1.6.3
   Compiling ordered-multimap v0.4.3
   Compiling gif v0.11.4
   Compiling libsqlite3-sys v0.25.2
   Compiling tungstenite v0.18.0
   Compiling x11rb v0.10.1
   Compiling rustls-pemfile v1.0.2
   Compiling ecdsa v0.16.1
   Compiling tiff v0.8.1
   Compiling pbkdf2 v0.12.1
   Compiling salsa20 v0.10.2
   Compiling tokio-util v0.7.7
   Compiling tokio-rustls v0.23.4
   Compiling async-compression v0.3.15
   Compiling chacha20 v0.9.0
   Compiling kurbo v0.8.3
   Compiling aead v0.5.1
   Compiling h2 v0.3.16
   Compiling rtoolbox v0.0.1
   Compiling glutin-winit v0.3.0
   Compiling simplecss v0.2.1
   Compiling encoding_rs v0.8.32
   Compiling data-url v0.2.0
   Compiling imagesize v0.10.1
   Compiling mime v0.3.16
   Compiling scoped_threadpool v0.1.9
   Compiling ipnet v2.7.1
   Compiling rctree v0.5.0
   Compiling convert_case v0.4.0
   Compiling libm v0.2.6
   Compiling dark-light v1.0.0
   Compiling usvg v0.28.0
   Compiling derive_more v0.99.17
   Compiling image v0.24.5
   Compiling rpassword v7.2.0
   Compiling enumflags2 v0.7.5
   Compiling zvariant v3.12.0
   Compiling accesskit v0.9.0
   Compiling serde-xml-rs v0.4.1
   Compiling ecolor v0.21.0 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling emath v0.21.0 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling ron v0.8.0
   Compiling serde_urlencoded v0.7.1
   Compiling chacha20poly1305 v0.10.1
   Compiling hyper v0.14.25
   Compiling epaint v0.21.0 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling scrypt v0.11.0
   Compiling k256 v0.13.0
   Compiling zbus_names v2.5.0
   Compiling zbus v3.11.0
   Compiling egui v0.21.0 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling accesskit_consumer v0.13.0
   Compiling hyper-rustls v0.23.2
   Compiling arboard v3.2.0
   Compiling regex-automata v0.1.10
   Compiling reqwest v0.11.14
   Compiling rust-ini v0.18.0
   Compiling smithay-clipboard v0.6.6
   Compiling rgb v0.8.36
   Compiling cbc v0.1.2
   Compiling aes v0.8.2
   Compiling webbrowser v0.8.7
   Compiling dirs-sys-next v0.1.2
   Compiling overload v0.1.1
   Compiling bech32 v0.9.1
   Compiling pico-args v0.5.0
   Compiling core-net v0.1.0
   Compiling detect-desktop-environment v0.2.0
   Compiling dconf_rs v0.3.0
   Compiling glow v0.12.1
   Compiling iana-time-zone v0.1.53
   Compiling chrono v0.4.23
   Compiling memoize-inner v0.4.0
   Compiling nostr-types v0.4.0
   Compiling resvg v0.28.0
   Compiling egui_glow v0.21.0 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling nu-ansi-term v0.46.0
   Compiling directories-next v2.0.0
   Compiling matchers v0.1.0
   Compiling futures-executor v0.3.27
   Compiling lru v0.7.8
   Compiling dashmap v5.4.0
   Compiling hashlink v0.8.1
   Compiling tracing-log v0.1.3
   Compiling sharded-slab v0.1.4
   Compiling thread_local v1.1.7
   Compiling time-core v0.1.0
   Compiling checked_int_cast v1.0.0
   Compiling fallible-streaming-iterator v0.1.9
   Compiling fallible-iterator v0.2.0
   Compiling qrcode v0.12.0 (https://github.com/mikedilger/qrcode-rust?rev=519b77b3efa3f84961169b47d3de08c5ddd86548#519b77b3)
   Compiling time v0.3.20
   Compiling humansize v2.1.3
   Compiling gossip-relay-picker v0.1.0
   Compiling memoize v0.4.0
   Compiling futures v0.3.27
   Compiling egui_extras v0.21.0 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling tokio-tungstenite v0.18.0
   Compiling linkify v0.9.0
   Compiling tracing-subscriber v0.3.16
   Compiling atspi-macros v0.1.4
   Compiling atspi v0.8.7
   Compiling accesskit_unix v0.2.0
   Compiling accesskit_winit v0.10.0
   Compiling egui-winit v0.21.1 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling eframe v0.21.3 (https://github.com/mikedilger/egui?rev=4687a41b1af79be89181a45d35163090b5556e53#4687a41b)
   Compiling rusqlite v0.28.0
   Compiling gossip v0.5.2 (/build/source)
error[E0412]: cannot find type `Id` in module `task`
  --> src/overlord/mod.rs:34:37
   |
34 |     minions_task_url: HashMap<task::Id, RelayUrl>,
   |                                     ^^ not found in `task`
   |
help: consider importing one of these items
   |
3  | use nostr_types::Id;
   |
3  | use tracing::Id;
   |
help: if you import `Id`, refer to it directly
   |
34 -     minions_task_url: HashMap<task::Id, RelayUrl>,
34 +     minions_task_url: HashMap<Id, RelayUrl>,
   |

error[E0412]: cannot find type `Id` in module `task`
   --> src/overlord/mod.rs:380:47
    |
380 |         task_nextjoined: Option<Result<(task::Id, ()), task::JoinError>>,
    |                                               ^^ not found in `task`
    |
help: consider importing one of these items
    |
3   | use nostr_types::Id;
    |
3   | use tracing::Id;
    |
help: if you import `Id`, refer to it directly
    |
380 -         task_nextjoined: Option<Result<(task::Id, ()), task::JoinError>>,
380 +         task_nextjoined: Option<Result<(Id, ()), task::JoinError>>,
    |

error[E0599]: no method named `join_next_with_id` found for struct `JoinSet` in the current scope
  --> src/overlord/mod.rs:71:48
   |
71 |             let task_nextjoined = self.minions.join_next_with_id().await;
   |                                                ^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `join_next`

error[E0599]: no method named `id` found for struct `tokio::task::AbortHandle` in the current scope
   --> src/overlord/mod.rs:333:31
    |
333 |         let id = abort_handle.id();
    |                               ^^ method not found in `tokio::task::AbortHandle`

error[E0599]: no method named `join_next_with_id` found for struct `JoinSet` in the current scope
   --> src/overlord/mod.rs:369:48
    |
369 |                 task_nextjoined = self.minions.join_next_with_id() => {
    |                                                ^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `join_next`

Some errors have detailed explanations: E0412, E0599.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `gossip` due to 5 previous errors
error: builder for '/nix/store/1h8zjbwb57z23rsdnrhdhhm18dd50vxn-gossip-0.5.2.drv' failed with exit code 101;
       last 10 log lines:
       >
       > error[E0599]: no method named `join_next_with_id` found for struct `JoinSet` in the current scope
       >    --> src/overlord/mod.rs:369:48
       >     |
       > 369 |                 task_nextjoined = self.minions.join_next_with_id() => {
       >     |                                                ^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `join_next`
       >
       > Some errors have detailed explanations: E0412, E0599.
       > For more information about an error, try `rustc --explain E0412`.
       > error: could not compile `gossip` due to 5 previous errors
       For full logs, run 'nix log /nix/store/1h8zjbwb57z23rsdnrhdhhm18dd50vxn-gossip-0.5.2.drv'.

There have been several issues…

  1. You can not just add another rust version to the nativeBuildInputs, instead you need to create a new rustPlatform, and I also pinned rust overlay and rust version:

    diff --git a/default.nix b/default.nix
    index 0095172..617be01 100644
    --- a/default.nix
    +++ b/default.nix
    @@ -1,10 +1,15 @@
     with import <nixpkgs> {
    
       overlays = [
    -    (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
    +   (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/18cdcb7b4017f266117a4d164f9d71c0535ef5ec.tar.gz"))
       ];
     };
    
    +let rustPlatform = makeRustPlatform rec {
    +  rustc = rust-bin.stable."1.65.0".default;
    +  cargo = rustc;
    +};
    +in
     rustPlatform.buildRustPackage rec {
       pname = "gossip";
       version = "0.4.2";
    @@ -13,7 +18,6 @@ nativeBuildInputs = [
         pkg-config
         openssl
         fontconfig
    -    rust-bin.beta.latest.default
     ];
    
     src = fetchFromGitHub {
    

    This will make it use the correct version.

  2. There are git dependencies in the lock file, buildRustPackage doesn’t like that and needs some help. This is the IFD version to make it work quickly. If you want to upstream this to nixpkgs, you need to copy the Cargo.lock.

    diff --git a/default.nix b/default.nix
    index 617be01..08e1b3b 100644
    --- a/default.nix
    +++ b/default.nix
    @@ -27,7 +27,11 @@ src = fetchFromGitHub {
       sha256 = "Qr8XXXdIyVjPhu+bmeMlxQpfxtUKBgP94HonSQzryro=";
     };
    
    -cargoSha256 = "2DsAWg9hrYCX4MHeR1O95vKMxeY3dgK80XecndGoHPY=";
    +cargoLock.lockFile = "${src}/Cargo.lock";
    +cargoLock.outputHashes = {
    +  "nostr-types-0.4.0-unstable" = "sha256-RHpn6bh0UhEOVZJOaT+hnzKGGbv45yqpv4jKh6fDG88=";
    +  "qrcode-0.12.0" = "sha256-onnoQuMf7faDa9wTGWo688xWbmujgE9RraBialyhyPw=";
    +};
    
     postInstall = ''
    
  3. .cargo/config seems to be ignored by builtRustPackage, so I had to set appropriate RUSTFLAGS to mimic the given cargo-config from the repository.

    diff --git a/default.nix b/default.nix
    index 08e1b3b..3cfdfd0 100644
    --- a/default.nix
    +++ b/default.nix
    @@ -33,6 +33,7 @@ cargoLock.outputHashes = {
       "qrcode-0.12.0" = "sha256-onnoQuMf7faDa9wTGWo688xWbmujgE9RraBialyhyPw=";
     };
    
    +RUSTFLAGS = "--cfg tokio_unstable";
    
     postInstall = ''
                     mkdir -p $out/share/applications/
    
  4. target/release/gossip doesn’t exist in the build folder, but buildRustPackage does take care of copying that anyway, so I just removed that from the postInstall.

    diff --git a/default.nix b/default.nix
    index 3cfdfd0..b71ea63 100644
    --- a/default.nix
    +++ b/default.nix
    @@ -38,7 +38,6 @@ RUSTFLAGS = "--cfg tokio_unstable";
     postInstall = ''
                     mkdir -p $out/share/applications/
                     cp packaging/debian/gossip.desktop $out/share/applications/
    -                cp target/release/gossip $out/bin/
                   '';
    
     meta = with lib; {
    

This will still create a broken binary, something in it seems to try to load shared objects using dlopen, which regularly causes some issues with graphical rust programs, as most frameworks use that rather than dynamic linkage.

How to solve the issue with that depends on the used GUI crates, I am not in the mood going through that, given that each iteration to build this takes ~30 minutes on my machine.

Full diff
diff --git a/default.nix b/default.nix
index 0095172..b71ea63 100644
--- a/default.nix
+++ b/default.nix
@@ -1,10 +1,15 @@
 with import <nixpkgs> {
   
   overlays = [
-    (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
+   (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/18cdcb7b4017f266117a4d164f9d71c0535ef5ec.tar.gz"))
   ];
 };
 
+let rustPlatform = makeRustPlatform rec {
+  rustc = rust-bin.stable."1.65.0".default;
+  cargo = rustc;
+};
+in
 rustPlatform.buildRustPackage rec {
   pname = "gossip";
   version = "0.4.2";
@@ -13,7 +18,6 @@ nativeBuildInputs = [
     pkg-config
     openssl
     fontconfig
-    rust-bin.beta.latest.default
 ];
 
 src = fetchFromGitHub {
@@ -23,13 +27,17 @@ src = fetchFromGitHub {
   sha256 = "Qr8XXXdIyVjPhu+bmeMlxQpfxtUKBgP94HonSQzryro=";
 };
 
-cargoSha256 = "2DsAWg9hrYCX4MHeR1O95vKMxeY3dgK80XecndGoHPY=";
+cargoLock.lockFile = "${src}/Cargo.lock";
+cargoLock.outputHashes = {
+  "nostr-types-0.4.0-unstable" = "sha256-RHpn6bh0UhEOVZJOaT+hnzKGGbv45yqpv4jKh6fDG88=";
+  "qrcode-0.12.0" = "sha256-onnoQuMf7faDa9wTGWo688xWbmujgE9RraBialyhyPw=";
+};
 
+RUSTFLAGS = "--cfg tokio_unstable";
 
 postInstall = ''
                 mkdir -p $out/share/applications/
                 cp packaging/debian/gossip.desktop $out/share/applications/
-                cp target/release/gossip $out/bin/
               '';
 
 meta = with lib; {
1 Like

Thanks for the help. Okay, looks like I was mistaken in terms of adding the rust version. This was my understanding based on the oxalica docs. I’ll take a look at this and work to solve the issue.

hi @jasonodoom did you find a solution to your problem?

I’m trying to find a way to run gossip on nixos.

hi @bernardoaraujor , sorry for the late reply. I’ve not resumed this in a while but I believe I’ve the latest information to proceed. Though I no longer use Nostr so I’m not too committed in getting this done immediately. I can resume work on this if you’re looking to use the client.

I wanted to run it mostly for exploration and curiosity, no serious reason. So no need to rush this because of me.

I would already be really grateful if you notified me here once this is ready.

I’m also willing to help out if necessary, although I’m a bit of a newbie when it comes to nix.

Sounds good! I will make time to resume work on this.

1 Like