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

nixos/modules/installer/sd-card/sd-image-mips64el.nix: init #194153

Closed
wants to merge 4 commits into from
Closed

nixos/modules/installer/sd-card/sd-image-mips64el.nix: init #194153

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 3, 2022

Description of changes

This cross-compiles a complete NixOS installer image.

Includes:

For cross compilation, you will need:

@github-actions github-actions bot added 6.topic: kernel The Linux kernel 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Oct 3, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Oct 3, 2022
@ghost ghost marked this pull request as ready for review April 24, 2023 21:16
@ghost
Copy link
Author

ghost commented Apr 24, 2023

Okay, this builds again. I will try booting it tonight.

@ghost

This comment was marked as outdated.

@ghost

This comment was marked as outdated.

@ghost

This comment was marked as outdated.

@ghost
Copy link
Author

ghost commented Jul 19, 2023

@ofborg build pkgsCross.octeon.linux

@ghost
Copy link
Author

ghost commented Jul 19, 2023

pkgsCross.octeon.linux on x86_64-linux — Success Details

@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 20, 2023
@ghost ghost changed the base branch from master to staging July 28, 2023 22:33
@ghost
Copy link
Author

ghost commented Jul 28, 2023

Switched branches to staging in order to pick up #245449; will switch back on next staging->master merge.

@github-actions github-actions bot removed the 6.topic: kernel The Linux kernel label Jul 28, 2023
@ghost
Copy link
Author

ghost commented Jul 28, 2023

@ofborg build pkgsCross.octeon.linux_latest

@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 28, 2023
Comment on lines 24 to 26

nixpkgs.buildPlatform = builtins.currentSystem;
nixpkgs.hostPlatform = lib.systems.examples.octeon;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I can review anything else, but there's at least this.

This would need to use mips64el (since it's the name of the file) or rename the file for octeon. I'd prefer targeting the generic mips64el and users needing octeon can provide a host platform.

But actually, with a bit more thought, SD/ISO builds should be made assuming native builds. Cross-compiling usage is done externally through configuring platforms. Look at all the other existing sd image configs. So actually removing the lines is the correct resolution here.

Suggested change
nixpkgs.buildPlatform = builtins.currentSystem;
nixpkgs.hostPlatform = lib.systems.examples.octeon;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roberth is insisting that it be done this way -- through module parameters.

Perhaps one of you can convince the other.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I left a comment on the other PR)

There is no convincing to do, and we agree, and this comment here agrees with the idea that cross-compilation is configured through the NixOS configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is a "profile" module that's specifically about mips64el, so it does make sense to set a default hostPlatform, but buildPlatform is not specific to mips64el hosts and therefore shouldn't be set here.

@ghost ghost requested a review from samueldr July 29, 2023 19:53
@ghost ghost mentioned this pull request Jul 31, 2023
12 tasks
Adam Joseph added 3 commits August 1, 2023 15:27
…latform

p11-kit does not cross-compile.  This prevents the NixOS installer
from cross-compiling.  Therefore, we mark it broken in this case and
omit it.
The libnvme documentation fails to build when cross compiling, with:

 FAILED: doc/nvme_admin_opcode.2
 /nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/bin/meson --internal exe --capture doc/nvme_admin_opcode.2 -- /build/source/doc/kernel-doc -module libnvme -man -function nvme_admin_opcode ../doc/../src/nvme/types.h
 Traceback (most recent call last):
   File "/nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/bin/meson", line 6, in <module>
   File "/nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 30, in <module>
     from . import mlog
 ImportError: cannot import name 'mlog' from 'mesonbuild' (/nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/lib/python3.10/site-packages/mesonbuild/__init__.py)
 [703/811] Generating doc/nvme_identify_cns_man with a custom command (wrapped by meson to capture output)
 FAILED: doc/nvme_identify_cns.2
 /nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/bin/meson --internal exe --capture doc/nvme_identify_cns.2 -- /build/source/doc/kernel-doc -module libnvme -man -function nvme_identify_cns ../doc/../src/nvme/types.h
 Traceback (most recent call last):
   File "/nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/bin/meson", line 6, in <module>
   File "/nix/store/qcvcsink30f4wh36jzg3rbvkshwzj38c-meson-1.1.1/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 30, in <module>
     from . import mlog
@ghost
Copy link
Author

ghost commented Aug 1, 2023

Rebased.

This cross-compiles a complete NixOS installer image.

The image is built specifically for Cavium Octeon chips, because currently these
are the Mips64 products that are commercially available: you can order a
Ubiquiti Edgerouter from Amazon and have it the next day.  All of Debian's
non-Longsoon MIPS builders are Octeons: https://wiki.debian.org/MIPSPort

Co-authored-by: Samuel Dionne-Riel <[email protected]>
@ghost ghost mentioned this pull request Aug 2, 2023
12 tasks
@ghost
Copy link
Author

ghost commented Aug 2, 2023

The full installer builds from x86_64-linux at ed45b4a:

$ git rev-parse HEAD
ed45b4a9965c13459e92c014abd3da33329f14fe

$ nix-instantiate \
  nixos \
  -A config.system.build.sdImage \
  --arg configuration '{config,lib,pkgs,...}@args: (import ./nixos/modules/installer/sd-card/sd-image-mips64el.nix args) // { nixpkgs.hostPlatform = lib.systems.examples.octeon; nixpkgs.buildPlatform = builtins.currentSystem; }' --keep-going --show-trace

trace: warning: system.stateVersion is not set, defaulting to 23.11. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/90gvixdily6k0hvk47fzhcrc5439lhn5-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64.drv

$ nix-build /nix/store/90gvixdily6k0hvk47fzhcrc5439lhn5-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64.drv
...
Preparing store paths for image...
Creating an EXT4 image of 2512502784 bytes (numInodes=60520, numDataBlocks=492364)
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 613404 4k blocks and 153520 inodes
Filesystem UUID: 44444444-4444-4444-8888-888888888888
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Copying files into the device: done
Writing superblocks and filesystem accounting information: done

e2fsck 1.47.0 (5-Feb-2023)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
NIXOS_SD: 60038/153520 files (0.1% non-contiguous), 494819/613404 blocks
resize2fs 1.47.0 (5-Feb-2023)
The filesystem is already 613404 (4k) blocks long.  Nothing to do!

dumpe2fs 1.47.0 (5-Feb-2023)
resize2fs 1.47.0 (5-Feb-2023)
Resizing the filesystem on temp.img to 617500 (4k) blocks.
The filesystem on temp.img is now 617500 (4k) blocks long.

Compressing image
*** Zstandard CLI (64-bit) v1.5.5, by Yann Collet ***
./temp.img           : 36.58%   (  2.36 GiB =>    882 MiB, /nix/store/3rgrmmr28fl9r1j4mpd4k4jp0cb4adj0-ext4-fs.img.zst-mips64el-unknown-linux-gnuabi64)
Decompressing rootfs image
/nix/store/3rgrmmr28fl9r1j4mpd4k4jp0cb4adj0-ext4-fs.img.zst-mips64el-unknown-linux-gnuabi64: 2529280000 bytes
Checking that no-one is using this disk right now ... OK

Disk /nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img: 2.39 GiB, 2569125888 bytes, 5017824 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS (MBR) disklabel with disk identifier 0x2178694e.
/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img1: Created a new partition 1 of type 'W95 FAT32' and of size 30 MiB.
/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img2: Created a new partition 2 of type 'Linux' and of size 2.4 GiB.
/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img3: Done.

New situation:
Disklabel type: dos
Disk identifier: 0x2178694e

Device                                                                                                                                                                              Boot Start     End Sectors  Size Id Type
/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img1      16384   77823   61440   30M  b W95
/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img2 *    77824 5017823 4940000  2.4G 83 Linu

The partition table has been altered.
Syncing disks.

4940000+0 records in
4940000+0 records out
2529280000 bytes (2.5 GB, 2.4 GiB) copied, 13.6199 s, 186 MB/s
mkfs.fat 4.2 (2021-01-31)
fsck.fat 4.2 (2021-01-31)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
      2048 bytes per cluster
         4 reserved sectors
First FAT starts at byte 2048 (sector 4)
         2 FATs, 16 bit entries
     30720 bytes per FAT (= 60 sectors)
Root directory starts at byte 63488 (sector 124)
       512 root directory entries
Data area starts at byte 79872 (sector 156)
     15321 data clusters (31377408 bytes)
32 sectors/track, 4 heads
         0 hidden sectors
     61440 sectors total
Checking for unused clusters.
firmware_part.img: 1 files, 0/15321 clusters
61440+0 records in
61440+0 records out
31457280 bytes (31 MB, 30 MiB) copied, 0.155094 s, 203 MB/s
/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img : 36.01%   (  2.39 GiB =>    882 MiB, /nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64/sd-image/nixos-sd-image-23.11pre-git-mips64el-linux.img.zst)

/nix/store/zly6i97rzgvj9jirhwkwwy8zvqp2pxqn-nixos-sd-image-23.11pre-git-mips64el-linux.img-mips64el-unknown-linux-gnuabi64

@ghost ghost closed this Jan 23, 2024
@ghost ghost deleted the pr/installer/mips branch January 23, 2024 06:48
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/binary-cache-for-riscv64/44934/3

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: kernel The Linux kernel 6.topic: lib The Nixpkgs function library 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: systemd 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants