Skip to content

Commit 5c94d3f

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

5 files changed

Lines changed: 70 additions & 39 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@ env:
1010
IMAGE_NAME: ${{ github.repository }}
1111

1212
jobs:
13-
build-linux:
14-
runs-on: ubuntu-latest
15-
permissions:
16-
contents: read
17-
packages: write
18-
outputs:
19-
linux-image: ${{ steps.meta.outputs.tags }}
20-
steps:
21-
- name: Set up Docker Buildx
22-
uses: docker/setup-buildx-action@v3
13+
# build-linux:
14+
# runs-on: ubuntu-latest
15+
# permissions:
16+
# contents: read
17+
# packages: write
18+
# outputs:
19+
# linux-image: ${{ steps.meta.outputs.tags }}
20+
# steps:
21+
# - name: Set up Docker Buildx
22+
# uses: docker/setup-buildx-action@v3
2323

24-
- name: Login to GitHub Container Registry
25-
uses: docker/login-action@v3
26-
with:
27-
registry: ${{ env.REGISTRY }}
28-
username: ${{ github.actor }}
29-
password: ${{ secrets.GITHUB_TOKEN }}
24+
# - name: Login to GitHub Container Registry
25+
# uses: docker/login-action@v3
26+
# with:
27+
# registry: ${{ env.REGISTRY }}
28+
# username: ${{ github.actor }}
29+
# password: ${{ secrets.GITHUB_TOKEN }}
3030

31-
- name: Docker meta
32-
id: meta
33-
uses: docker/metadata-action@v5
34-
with:
35-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-linux
31+
# - name: Docker meta
32+
# id: meta
33+
# uses: docker/metadata-action@v5
34+
# with:
35+
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-linux
3636

37-
- name: Build
38-
uses: docker/build-push-action@v5
39-
with:
40-
push: ${{ github.event_name != 'pull_request' }}
41-
tags: ${{ steps.meta.outputs.tags }}
42-
target: linux-build
43-
cache-from: type=gha
44-
cache-to: type=gha,mode=max
37+
# - name: Build
38+
# uses: docker/build-push-action@v5
39+
# with:
40+
# push: ${{ github.event_name != 'pull_request' }}
41+
# tags: ${{ steps.meta.outputs.tags }}
42+
# target: linux-build
43+
# cache-from: type=gha
44+
# cache-to: type=gha,mode=max
4545

4646
build:
4747
runs-on: ubuntu-latest
@@ -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)