Skip to content

Commit aff91f0

Browse files
committed
Add docker image builder in nix
1 parent 8aa3ed1 commit aff91f0

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

.github/workflows/docker-image.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,23 @@ jobs:
5353
matrix:
5454
os:
5555
- version: '2.15.1.1189'
56-
target: qemu-toltec
57-
- version: '3.3.2.1666'
58-
target: qemu-toltec
59-
- version: '3.5.2.1807'
60-
target: qemu-toltec
61-
- version: '3.8.2.1965'
62-
target: qemu-toltec
63-
- version: '3.20.0.92'
64-
target: qemu-toltec
56+
target: nix-toltec
57+
# - version: '3.3.2.1666'
58+
# target: qemu-toltec
59+
# - version: '3.5.2.1807'
60+
# target: qemu-toltec
61+
# - version: '3.8.2.1965'
62+
# target: qemu-toltec
63+
# - version: '3.20.0.92'
64+
# target: qemu-toltec
6565

6666
steps:
6767
- name: Set up Docker Buildx
6868
uses: docker/setup-buildx-action@v3
6969

70+
- uses: actions/checkout@v4
71+
- uses: cachix/install-nix-action@v31
72+
7073
- name: Login to GitHub Container Registry
7174
uses: docker/login-action@v3
7275
with:
@@ -83,6 +86,12 @@ jobs:
8386
latest=auto
8487
suffix=-${{matrix.os.target}}-${{ matrix.os.version }},onlatest=true
8588
89+
- name: Nix Build
90+
run: |
91+
nix build .#"docker-${{ matrix.os.version }}"
92+
./result | docker image load
93+
94+
8695
- name: Build
8796
uses: docker/build-push-action@v5
8897
with:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ RUN nix build "/src#\"rm-emu-$fw_version\"" -o /result && \
182182

183183
CMD run_vm
184184

185-
FROM nix-emu AS nix-start
185+
FROM rm-emu:$fw_version AS nix-start
186186

187187
# First boot, disable xochitl and reboot service, and save state
188188
RUN run_vm -serial null -daemonize && \

bin/run_vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ssh_port=${SSH_PORT:-22}
1010

1111
if ! [ -f "$root_path" ] && [ -f "$backing_path" ]; then
1212
echo "No image found, creating new one"
13+
mkdir -p $(dirname $root_path)
1314
qemu-img create -b "$backing_path" -F qcow2 -f qcow2 "$root_path"
1415
fi
1516

flake.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,33 @@
4141
inherit kernel rootfs;
4242
})
4343
) allRootFs;
44+
45+
dockerImages = nixpkgs.lib.mapAttrs' (
46+
_: pkg:
47+
nixpkgs.lib.nameValuePair "docker-${pkg.version}" (
48+
pkgs.dockerTools.streamLayeredImage {
49+
name = "rm-emu";
50+
tag = "${pkg.version}";
51+
contents = [
52+
pkg
53+
pkgs.dockerTools.binSh
54+
pkgs.dockerTools.fakeNss
55+
];
56+
57+
config = {
58+
Cmd = [ "${pkg}/bin/run_vm" ];
59+
};
60+
}
61+
)
62+
) allEmus;
4463
in
4564
{
4665
inherit kernel extractor;
4766
default = allEmus."rm-emu-3.20.0.92";
4867
}
4968
// allEmus
5069
// allRootFs'
70+
// dockerImages
5171
);
5272
};
5373
}

nix/rm-emu.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ stdenvNoCC.mkDerivation {
8383
lib.makeBinPath [
8484
qemu
8585
gnugrep
86+
coreutils
8687
]
8788
}
8889

0 commit comments

Comments
 (0)