Tweak 04

[?]
Mar 22, 2023, 2:12 PM
WK2OO4YYGVZKCIVSA43GW3WDUQ4UEUHF2GGY4WNWOZYISPFYWMDAC

Dependencies

Change contents

  • edit in 04-cmake-and-cross/flake.nix at line 26
    [5.4591]
    [3.701]
    # The 'default' package is the package injected into our package set
  • edit in 04-cmake-and-cross/flake.nix at line 28
    [3.747]
    [5.4895]
    # But the package set also has a pkgsCross set, and we can select our package from one of its contents
    packages.cross-riscv64 = pkgs.pkgsCross.riscv64.wttr-delft;
  • replacement in 04-cmake-and-cross/demo.sh at line 15
    [3.1100][3.1100:1214]()
    , Packaging in this way and making use of the sandboxed Nix build process can hepl find missing dependencies etc.
    [3.1100]
    [3.1214]
    , Packaging in this way and making use of the sandboxed Nix build process
    , can help find dependencies that were not correctly declared etc.
  • edit in 04-cmake-and-cross/demo.sh at line 33
    [3.1610]
    [3.1610]
    , The previous build was for x86_64-linux by default because that is our current system:
    x "${file_cmd}" ./result/bin/wttr-delft
  • replacement in 04-cmake-and-cross/demo.sh at line 36
    [3.1611][3.1611:1658]()
    , We can very easily set up cross-compilation.
    [3.1611]
    [3.1658]
    h We can very easily set up cross-compilation.
  • replacement in 04-cmake-and-cross/demo.sh at line 40
    [3.1785][3.1785:1833]()
    , If we take a look at what the flake provides:
    [3.1785]
    [3.1833]
    , Now we can call a different output:
    x nix build "${dir}#cross-riscv64"
    , And this is indeed a RISC-V binary:
    x "${file_cmd}" ./result/bin/wttr-delft
    h Emulation
    , If we take a look at what the flake provides we see multiple architectures as well:
  • replacement in 04-cmake-and-cross/demo.sh at line 49
    [3.1860][3.1860:1949](),[3.1949][2.104:144]()
    h The previous build was for x86_64-linux by default because that is our current system:
    x "${file_cmd}" ./result/bin/wttr-delft
    [3.1860]
    [3.1980]
    n This will not work if the emulation is not available:
    , But, if you use NixOS it\'s also very simple to set up binfmt to emulate e.g. aarch64-linux!
  • edit in 04-cmake-and-cross/demo.sh at line 52
    [3.1981][3.1981:2052]()
    h But we can easily build for aarch64-linux \(e.g. for Raspberry Pi\):
  • edit in 04-cmake-and-cross/demo.sh at line 55
    [3.2139][3.2139:2234](),[3.2234][2.186:187]()
    n If you use NixOS it\'s also very simple to set up binfmt to still be able to run the binary!