Skip to content

Commit 151b4f7

Browse files
committed
Large-scale refactor of Nix flake.
- Fixes the Nix build by removing the absolute path to Bash. - Changes packages to be named "name/target" instead of "name-target" - Target names also have hyphens in them, so parsing them is a bit of a pain. - Removes aliases for components of the image. These are still exposed as passthru attributes, but they don't have the target name in them any more. This should be more consistent and simpler to program around. - Uses a "g" prefix for non-release versions instead of another hyphenated component. This again reduces ambiguity in parsing paths. - Adds flake checks that all the ukoOS builds succeed and all the image builds succeed, and runs these checks in GitHub Actions. - Prepares GitHub Actions to be used with other image targets (e.g. #56). This is done through the all-images package; whatever files that builds will get uploaded as artifacts. - Fixes the REUSE tool being added as a dependency of ukoos instead of as a devShell input. Signed-off-by: Nathan Ringo <me@remexre.com>
1 parent 03b08e2 commit 151b4f7

File tree

11 files changed

+88
-51
lines changed

11 files changed

+88
-51
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
name: ukoos-${{ matrix.target }}-git.tar.zst
6161
path: ukoos-${{ matrix.target }}-git.tar.zst
6262
compression-level: 0
63-
build-dev-image:
63+
build-images:
6464
runs-on: ubuntu-latest
6565
steps:
6666
- uses: actions/checkout@v4
@@ -71,12 +71,14 @@ jobs:
7171
with:
7272
name: ukoos
7373
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
74-
- name: Build
74+
- name: Run checks
75+
run: |
76+
nix flake check -L
77+
- name: Build images
7578
run: |
76-
nix build -L .#dev-image-milkv-duos
77-
cp result/sdcard.img dev-image-milkv-duos-sdcard.img
78-
- name: Upload Artifact
79+
nix build -L .#all-images
80+
- name: Upload images
7981
uses: actions/upload-artifact@v4
8082
with:
81-
name: dev-image-milkv-duos-sdcard.img
82-
path: dev-image-milkv-duos-sdcard.img
83+
name: images
84+
path: result/

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ endif
1212
.DEFAULT_GOAL = all
1313
MAKEFLAGS += -rR
1414

15-
# Set bash as the shell
16-
SHELL = /bin/bash
15+
# Set bash as the shell.
16+
SHELL := $(shell command -v bash)
1717

1818
# Helpers.
1919
ifeq ($(V),1)

flake.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
inputs.u-boot-milkv-duos = {
2+
inputs.u-boot-milkv-duos-sd = {
33
url = "github:UMN-Kernel-Object/u-boot/milkv-duos-sd";
44
inputs = {
55
flake-utils.follows = "flake-utils";
@@ -11,18 +11,27 @@
1111
self,
1212
flake-utils,
1313
nixpkgs,
14-
u-boot-milkv-duos,
14+
u-boot-milkv-duos-sd,
1515
}:
1616
flake-utils.lib.eachDefaultSystem (
1717
system:
1818
let
1919
pkgs = nixpkgs.legacyPackages.${system};
20-
version = "git-${self.shortRev or self.dirtyShortRev or "unknown"}";
20+
version = "g${self.shortRev or self.dirtyShortRev or "unknown"}";
21+
22+
all-targets = [
23+
"milkv-duos"
24+
"milkv-jupiter"
25+
"qemu-riscv64"
26+
];
27+
all-image-targets = [
28+
"milkv-duos-sd"
29+
];
2130

2231
ukoos =
23-
arch: target:
32+
target:
2433
pkgs.stdenvNoCC.mkDerivation {
25-
pname = "ukoos-${arch}-${target}";
34+
pname = "ukoos-${target}";
2635
inherit version;
2736

2837
src = ./.;
@@ -33,7 +42,6 @@
3342
pkgs.pkgsCross.riscv64-embedded.stdenv.cc.bintools.bintools
3443
pkgs.pkgsCross.riscv64-embedded.stdenv.cc.cc
3544
pkgs.python3
36-
pkgs.reuse
3745
];
3846

3947
dontUnpack = true;
@@ -42,7 +50,7 @@
4250
4351
mkdir build
4452
cd build
45-
GDB=false bash $src/configure --arch ${arch} --target ${target}
53+
GDB=false bash $src/configure --target ${target}
4654
4755
runHook postConfigure
4856
'';
@@ -54,18 +62,35 @@
5462
runHook postInstall
5563
'';
5664
};
65+
ukoos-packages = builtins.listToAttrs (
66+
builtins.map (target: {
67+
name = "ukoos/${target}";
68+
value = ukoos target;
69+
}) all-targets
70+
);
5771
in
5872
rec {
73+
checks = {
74+
build-ukoos-for-all-targets = pkgs.linkFarm "ukoos-all-targets" (
75+
builtins.map (target: {
76+
name = target;
77+
path = packages."ukoos/${target}";
78+
}) all-targets
79+
);
80+
build-images-for-all-targets = packages.all-images;
81+
};
82+
5983
devShells.default = pkgs.mkShell {
6084
inputsFrom = [
61-
packages.ukoos-milkv-duos
85+
packages."ukoos/qemu-riscv64"
6286
];
6387
nativeBuildInputs = [
6488
pkgs.bear
6589
pkgs.dtc
6690
pkgs.gdb
6791
pkgs.minicom
6892
pkgs.qemu
93+
pkgs.reuse
6994
];
7095
shellHook = ''
7196
export CC=riscv64-none-elf-gcc
@@ -74,23 +99,32 @@
7499
'';
75100
};
76101

77-
packages = {
78-
default = packages.ukoos-milkv-duos;
102+
packages = ukoos-packages // {
103+
default = packages."ukoos/milkv-duos";
79104

80-
ukoos-milkv-duos = ukoos "riscv64" "milkv-duos";
81-
ukoos-milkv-jupiter = ukoos "riscv64" "milkv-jupiter";
82-
ukoos-qemu-riscv64 = ukoos "riscv64" "qemu-riscv64";
105+
all-images = pkgs.linkFarm "ukoos-images" (
106+
builtins.concatMap (image-target: [
107+
{
108+
name = "dev-image-${image-target}.img";
109+
path = "${packages."dev-image/${image-target}"}/ukoos.img";
110+
}
111+
{
112+
name = "image-${image-target}.img";
113+
path = "${packages."image/${image-target}"}/ukoos.img";
114+
}
115+
]) all-image-targets
116+
);
83117

84-
dev-image-milkv-duos = pkgs.callPackage ./src/image-milkv-duos {
118+
"dev-image/milkv-duos-sd" = pkgs.callPackage ./src/image-milkv-duos-sd {
85119
dev = true;
86-
inherit (packages) ukoos-milkv-duos u-boot-milkv-duos;
120+
u-boot-milkv-duos-sd = u-boot-milkv-duos-sd.packages.${system}.default;
121+
ukoos-milkv-duos = packages."ukoos/milkv-duos";
87122
};
88-
image-milkv-duos = pkgs.callPackage ./src/image-milkv-duos {
123+
"image/milkv-duos-sd" = pkgs.callPackage ./src/image-milkv-duos-sd {
89124
dev = false;
90-
inherit (packages) ukoos-milkv-duos u-boot-milkv-duos;
125+
u-boot-milkv-duos-sd = u-boot-milkv-duos-sd.packages.${system}.default;
126+
ukoos-milkv-duos = packages."ukoos/milkv-duos";
91127
};
92-
u-boot-milkv-duos = u-boot-milkv-duos.packages.${system}.default;
93-
inherit (packages.image-milkv-duos) fsbl-milkv-duos opensbi-milkv-duos;
94128
};
95129
}
96130
);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
dev ? false,
3-
u-boot-milkv-duos,
3+
u-boot-milkv-duos-sd,
4+
ukoos-milkv-duos,
45

56
callPackage,
67
lib,
@@ -10,7 +11,6 @@
1011
dosfstools,
1112
genimage,
1213
mtools,
13-
ukoos-milkv-duos,
1414
}:
1515

1616
stdenvNoCC.mkDerivation (self: {
@@ -21,7 +21,7 @@ stdenvNoCC.mkDerivation (self: {
2121
dosfstools
2222
genimage
2323
mtools
24-
u-boot-milkv-duos
24+
u-boot-milkv-duos-sd
2525
];
2626

2727
dontUnpack = true;
@@ -31,7 +31,7 @@ stdenvNoCC.mkDerivation (self: {
3131
${lib.optionalString (!dev) ''
3232
install -Dt root/boot ${ukoos-milkv-duos}/sys/kernel.elf
3333
''}
34-
install -Dt root/boot ${self.passthru.fsbl-milkv-duos}/fip.bin
34+
install -Dt root/boot ${self.passthru.fsbl}/fip.bin
3535
mkenvimage -s 0x20000 -o root/boot/uboot.env ${./u-boot.txt}
3636
genimage --config ${./genimage.cfg}
3737
@@ -40,18 +40,18 @@ stdenvNoCC.mkDerivation (self: {
4040
installPhase = ''
4141
runHook preInstall
4242
43-
install -Dt $out -m 0644 images/sdcard.img
43+
install -Dt $out -m 0644 images/ukoos.img
4444
4545
runHook postInstall
4646
'';
4747

4848
passthru = {
49-
fsbl-milkv-duos = callPackage ./fsbl.nix {
50-
inherit (self.passthru) opensbi-milkv-duos;
51-
inherit u-boot-milkv-duos;
49+
fsbl = callPackage ./fsbl.nix {
50+
inherit (self.passthru) opensbi u-boot;
5251
};
53-
opensbi-milkv-duos = pkgsCross.riscv64-musl.callPackage ./opensbi.nix {
54-
inherit u-boot-milkv-duos;
52+
opensbi = pkgsCross.riscv64-musl.callPackage ./opensbi.nix {
53+
inherit (self.passthru) u-boot;
5554
};
55+
u-boot = u-boot-milkv-duos-sd;
5656
};
5757
})

src/image-milkv-duos/fsbl-patches/0001-fix-xthead-extension-names.patch renamed to src/image-milkv-duos-sd/fsbl-patches/0001-fix-xthead-extension-names.patch

File renamed without changes.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2+
opensbi,
3+
u-boot,
4+
25
fetchFromGitHub,
36
pkgsCross,
47
stdenvNoCC,
58

6-
opensbi-milkv-duos,
7-
u-boot-milkv-duos,
89
python3,
910
}:
1011

@@ -70,8 +71,8 @@ stdenvNoCC.mkDerivation (self: {
7071
CROSS_COMPILE=riscv64-unknown-linux-musl- \
7172
DDR_CFG=ddr3_1866_x16 \
7273
LDFLAGS="--no-warn-rwx-segments $LDFLAGS" \
73-
LOADER_2ND_PATH=${u-boot-milkv-duos}/u-boot.bin \
74-
MONITOR_PATH=${opensbi-milkv-duos}/fw_dynamic.bin \
74+
LOADER_2ND_PATH=${u-boot}/u-boot.bin \
75+
MONITOR_PATH=${opensbi}/fw_dynamic.bin \
7576
OD_CLK_SEL=y \
7677
RTOS_ENABLE_FREERTOS=y
7778
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image sdcard.img {
1+
image ukoos.img {
22
hdimage {
33
partition-table-type = "mbr"
44
}

src/image-milkv-duos/opensbi-patches/0001-fix-build-with-binutils-238.patch renamed to src/image-milkv-duos-sd/opensbi-patches/0001-fix-build-with-binutils-238.patch

File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2+
u-boot,
3+
24
fetchFromGitHub,
35
fetchpatch,
46
pkgsCross,
57
stdenvNoCC,
6-
7-
u-boot-milkv-duos,
88
}:
99

1010
stdenvNoCC.mkDerivation {
@@ -57,7 +57,7 @@ stdenvNoCC.mkDerivation {
5757
''${enableParallelBuilding:+-j''${NIX_BUILD_CORES}} \
5858
CHIP_ARCH=CV181X \
5959
CROSS_COMPILE=riscv64-unknown-linux-musl- \
60-
FW_FDT_PATH=${u-boot-milkv-duos}/u-boot.dtb \
60+
FW_FDT_PATH=${u-boot}/u-boot.dtb \
6161
OPENSBI_PATH=$PWD \
6262
PLATFORM=generic
6363

0 commit comments

Comments
 (0)