!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

682 Members
Rust153 Servers

Load older messages


SenderMessageTime
22 Sep 2022
@dpc:matrix.orgdpcHow do I configure a piece of code to run in my (crane-base) derivation?21:34:45
@dpc:matrix.orgdpcAPI docs mentiones Phases and hooks: https://github.com/ipetkov/crane/blob/master/docs/API.md#optional-attributes-1021:35:14
@dpc:matrix.orgdpc But I can't figure out what exactly am I supposed to set to get something to run? I just need to chmod +x some files that were copied into the derivation. 21:35:46
@ngerstle:matrix.org@ngerstle:matrix.org joined the room.22:00:17
23 Sep 2022
@tengkuizdihar:matrix.orgIzdihar
In reply to @dpc:matrix.org
But I can't figure out what exactly am I supposed to set to get something to run? I just need to chmod +x some files that were copied into the derivation.
what do you want to run in those phases? Like a custom bash command?
01:24:46
@tengkuizdihar:matrix.orgIzdiharIf so, then which phase you're choosing will depend entirely on what you want to do. This is the order of the phases is explained here preBuild01:28:08
@tengkuizdihar:matrix.orgIzdihar * If so, then which phase you're choosing will depend entirely on what you want to do. This is the order of the phases is explained here https://nixos.org/manual/nixpkgs/stable/#sec-stdenv-phases01:28:19
@nbp:mozilla.orgnbp changed their display name from nbp to nbp (PTO until Oct 1st).17:55:19
@nbp:mozilla.orgnbp changed their display name from nbp (PTO until Oct 1st) to nbp.17:55:48
25 Sep 2022
@andreasfelix:matrix.orgFelix Andreas joined the room.22:17:07
27 Sep 2022
@x10an14:matrix.orgx10an14

Anyone know of a cross-compilation example that targets musl and uses rust-overlay?

I can't for the life of me figure this out. I've spent the past couple of hours trying to search and read up on it, but I feel like there's some crucial tidbits of ignorance that keep me in the dark.
All the rust docs refer to leveraging rustup, which AFAIU is kinda antheisis to the premise of Nix.

I'm finding the learning curve a bit too steep for me =/

I've attempted:

  • rust-toolchain.toml; ```toml
    [toolchain]
    targets = ["x86_64-unknown-linux-musl", "x86_64-unknown-linux-gnu"]
    `flake.nix`: ```nix
      overlays = [
        (import rust-overlay)
        (self: super: {
          rustToolchain =
            let
              rust = super.rust-bin;
            in
            if builtins.pathExists ./rust-toolchain.toml then
              rust.fromRustupToolchainFile ./rust-toolchain.toml
            else if builtins.pathExists ./rust-toolchain then
              rust.fromRustupToolchainFile ./rust-toolchain
            else
              rust.stable.latest.default;
        })
      ]
    
    And finally; cargo build --target 'x86_64-unknown-linux-musl'
18:24:57
@x10an14:matrix.orgx10an14 *

Anyone know of a cross-compilation example that targets musl and uses rust-overlay?

I can't for the life of me figure this out. I've spent the past couple of hours trying to search and read up on it, but I feel like there's some crucial tidbits of ignorance that keep me in the dark.
All the rust docs refer to leveraging rustup, which AFAIU is kinda antheisis to the premise of Nix.

I'm finding the learning curve a bit too steep for me =/

I've attempted:

  • rust-toolchain.toml;

    [toolchain]
    targets = ["x86\_64-unknown-linux-musl", "x86\_64-unknown-linux-gnu"]
    
    

    flake.nix:

      overlays = [
        (import rust-overlay)
        (self: super: {
          rustToolchain =
            let
              rust = super.rust-bin;
            in
            if builtins.pathExists ./rust-toolchain.toml then
              rust.fromRustupToolchainFile ./rust-toolchain.toml
            else if builtins.pathExists ./rust-toolchain then
              rust.fromRustupToolchainFile ./rust-toolchain
            else
              rust.stable.latest.default;
        })
      ]
    

    And finally; cargo build --target 'x86_64-unknown-linux-musl'

18:27:11
@x10an14:matrix.orgx10an14

As mentioned in the https://matrix.to/#/#nix:nixos.org channel, the end result I'm looking for is a reduction of my docker image;

# flake.nix
      # The rust binary
      cargo-details = (pkgs.lib.importTOML ./Cargo.toml);
      binary-name = cargo-details.package.name;
      binary-version = cargo-details.package.version;
      cargo-package = pkgs.rustPlatform.buildRustPackage {
        pname = binary-name;
        version = binary-version;

        src = self;
        cargoLock.lockFile = ./Cargo.lock;

        nativeBuildInputs = rust-tools;
        buildInputs = rust-tools;
      };

      # Docker image
      # TODO: Reduce container size (cargo release -> ~5MB vs docker image -> ~35MB)
      # Seems like glibc is at fault? Statically compile? Musl?
      #  -> $ tree -L 3 unpacked_dockerimage/layer/
      #  unpacked_dockerimage/layer/
      #  └── nix
      #      └── store
      #          ├── 39pvnhy2l6zlqrgh6vv861v8lj6wnz0r-assign-item-to-project-field-0.1.0
      #          ├── 6f66prpgx1qx4n6k450sxs3d157ia1ps-glibc-2.35-163
      #          ├── g7lwga9p547cqyi9ym35bk78m1r12rky-libunistring-1.0
      #          └── jna5qh81395w6xsalnl532pm9qvvvpjy-libidn2-2.3.2
      #
      #  6 directories, 0 files
      #  -> $ sudo du -hs unpacked_dockerimage/layer/nix/store/* | sort -h
      #  308K    unpacked_dockerimage/layer/nix/store/jna5qh81395w6xsalnl532pm9qvvvpjy-libidn2-2.3.2
      #  1,6M    unpacked_dockerimage/layer/nix/store/39pvnhy2l6zlqrgh6vv861v8lj6wnz0r-assign-item-to-project-field-0.1.0
      #  1,8M    unpacked_dockerimage/layer/nix/store/g7lwga9p547cqyi9ym35bk78m1r12rky-libunistring-1.0
      #  31M     unpacked_dockerimage/layer/nix/store/6f66prpgx1qx4n6k450sxs3d157ia1ps-glibc-2.35-163
      #
      docker-image = pkgs.dockerTools.buildImage {
        name = binary-name;
        tag = "v${binary-version}";
        config = {
          Cmd = ["${cargo-package}/bin/${binary-name}"];
        };
      }
18:28:34
@x10an14:matrix.orgx10an14 *

Anyone know of a cross-compilation example that targets musl and uses rust-overlay?

I can't for the life of me figure this out. I've spent the past couple of hours trying to search and read up on it, but I feel like there's some crucial tidbits of ignorance that keep me in the dark.
All the rust docs refer to leveraging rustup, which AFAIU is kinda antheisis to the premise of Nix.

I'm finding the learning curve a bit too steep for me =/

I've attempted:

  • rust-toolchain.toml;
[toolchain]
targets = ["x86\_64-unknown-linux-musl", "x86\_64-unknown-linux-gnu"]

flake.nix:

  overlays = [
    (import rust-overlay)
    (self: super: {
      rustToolchain =
        let
          rust = super.rust-bin;
        in
        if builtins.pathExists ./rust-toolchain.toml then
          rust.fromRustupToolchainFile ./rust-toolchain.toml
        else if builtins.pathExists ./rust-toolchain then
          rust.fromRustupToolchainFile ./rust-toolchain
        else
          rust.stable.latest.default;
    })
  ]

And finally; cargo build --target 'x86_64-unknown-linux-musl'

18:28:55
@x10an14:matrix.orgx10an14 *

Anyone know of a cross-compilation example that targets musl and uses rust-overlay?

I can't for the life of me figure this out. I've spent the past couple of hours trying to search and read up on it, but I feel like there's some crucial tidbits of ignorance that keep me in the dark.
All the rust docs refer to leveraging rustup, which AFAIU is kinda antheisis to the premise of Nix.

I'm finding the learning curve a bit too steep for me =/

I've attempted:

  • rust-toolchain.toml;
[toolchain]
targets = ["x86\_64-unknown-linux-musl", "x86\_64-unknown-linux-gnu"]

flake.nix:

  overlays = [
    (import rust-overlay)
    (self: super: {
      rustToolchain =
        let
          rust = super.rust-bin;
        in
        if builtins.pathExists ./rust-toolchain.toml then
          rust.fromRustupToolchainFile ./rust-toolchain.toml
        else if builtins.pathExists ./rust-toolchain then
          rust.fromRustupToolchainFile ./rust-toolchain
        else
          rust.stable.latest.default;
    })
  ]

And finally; cargo build --target 'x86_64-unknown-linux-musl'

18:30:00
@x10an14:matrix.orgx10an14 *

Anyone know of a cross-compilation example that targets musl and uses rust-overlay?

I can't for the life of me figure this out. I've spent the past couple of hours trying to search and read up on it, but I feel like there's some crucial tidbits of ignorance that keep me in the dark.
All the rust docs refer to leveraging rustup, which AFAIU is kinda antheisis to the premise of Nix.

I'm finding the learning curve a bit too steep for me =/

I've attempted:
rust-toolchain.toml;

[toolchain]
targets = ["x86\_64-unknown-linux-musl", "x86\_64-unknown-linux-gnu"]

flake.nix:

  overlays = [
    (import rust-overlay)
    (self: super: {
      rustToolchain =
        let
          rust = super.rust-bin;
        in
        if builtins.pathExists ./rust-toolchain.toml then
          rust.fromRustupToolchainFile ./rust-toolchain.toml
        else if builtins.pathExists ./rust-toolchain then
          rust.fromRustupToolchainFile ./rust-toolchain
        else
          rust.stable.latest.default;
    })
  ]

And finally; cargo build --target 'x86_64-unknown-linux-musl'

18:30:23
@zhaofeng:zhaofeng.liZhaofeng LiFor this, I'm currently using crane and it works fine: https://github.com/mars-research/miniond/blob/main/flake.nix18:36:32
@x10an14:matrix.orgx10an14

Zhaofeng Li: AFAICT this does not use rust-overlay?

I am for sure not able to parse your flake.nix. I looked into crane - and after reading what its README says, I can't tell how you add musl as a cross-compilation target?

18:46:53
@zhaofeng:zhaofeng.liZhaofeng Li It does use rust-overlay (see rust-bin) - I just imported it through another flake (mars-std). I added musl to the targets here: https://github.com/mars-research/miniond/blob/1cf92176880c1913eb1f89dcd514aeabb5d3f2cb/flake.nix#L27-L33 18:48:18
@x10an14:matrix.orgx10an14Ahh okay. I think I understand better than, thanks for the pointer. Will attempt more bashing head against wall now19:12:12
@x10an14:matrix.orgx10an14 * Ahh okay. I think I understand better now, thanks for the pointer. Will attempt more bashing head against wall now 19:13:49
@x10an14:matrix.orgx10an14 * Ahh okay. I think I understand better, thanks for the pointer. Will attempt more bashing head against wall now 19:13:59
@x10an14:matrix.orgx10an14Thanks! I finally managed with your hints =D (See parent commit too maybe): https://git.sr.ht/~x10an14/assign-item-to-project-field/commit/c990d950b25929bf58a3f5e4abd7e3ad69e55b5720:54:14
28 Sep 2022
@coolshaurya:community.rscoolshaurya changed their profile picture.17:33:40
30 Sep 2022
@codenode:matrix.orgcode node joined the room.02:50:00
@codenode:matrix.orgcode nodeHello ppl, I am trying to setup neovim with lsp, finding it hard to get rust-analyzer working02:52:52
@lara:uwu.isyaya left the room.12:35:15
@louib:matrix.orglouib joined the room.13:01:06
@x10an14:matrix.orgx10an14
In reply to @x10an14:matrix.org

Anyone know of a cross-compilation example that targets musl and uses rust-overlay?

I can't for the life of me figure this out. I've spent the past couple of hours trying to search and read up on it, but I feel like there's some crucial tidbits of ignorance that keep me in the dark.
All the rust docs refer to leveraging rustup, which AFAIU is kinda antheisis to the premise of Nix.

I'm finding the learning curve a bit too steep for me =/

I've attempted:
rust-toolchain.toml;

[toolchain]
targets = ["x86\_64-unknown-linux-musl", "x86\_64-unknown-linux-gnu"]

flake.nix:

  overlays = [
    (import rust-overlay)
    (self: super: {
      rustToolchain =
        let
          rust = super.rust-bin;
        in
        if builtins.pathExists ./rust-toolchain.toml then
          rust.fromRustupToolchainFile ./rust-toolchain.toml
        else if builtins.pathExists ./rust-toolchain then
          rust.fromRustupToolchainFile ./rust-toolchain
        else
          rust.stable.latest.default;
    })
  ]

And finally; cargo build --target 'x86_64-unknown-linux-musl'

I'm not able to make it work for nix build, yet I am able to make it work for cargo build --target... Here's a paste explaining my differences: https://paste.sr.ht/~x10an14/57e8d3d2014e44232692773affc74741b5776ddb

Could some kind samaritan take take a look and see if they can understand and tell me what's going on?

18:01:01
@zhaofeng:zhaofeng.liZhaofeng Li Add openssl to buildInputs, and pkg-config to nativeBuildInputs. This is because unlike the interactive shell, the Nix build environment is sandboxed and only has access to the given inputs. 18:33:12

There are no newer messages yet.


Back to Room ListRoom Version: 6