-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Dockerfile that allows efficient local builds
The Dockerfile essentially builds a docker image by downloading moergo-sc/zmk and the current main branch of moergo-sc/glove80-zmk-config, and then building the latter to warm up the image's nix store. When running the image, very little gets downloaded, and the image just builds glove80.uf2 and copies it back to the current directory. The provided `build.sh` script both builds and runs the docker image, calling docker with the appropriate arguments.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM nixpkgs/nix | ||
|
||
ENV PATH=/root/.nix-profile/bin:/usr/bin:/bin | ||
|
||
RUN set -e -x; \ | ||
nix-env -iA cachix -f https://cachix.org/api/v1/install; \ | ||
cachix use moergo-glove80-zmk-dev; \ | ||
mkdir -p /glove80-zmk-config/config; \ | ||
git clone -b main https://github.com/moergo-sc/zmk /glove80-zmk-config/src; \ | ||
: Pre-build zmk to populate the nix store with the dependencies; \ | ||
cd /glove80-zmk-config/src; \ | ||
nix-shell --run true --attr zmk . | ||
|
||
RUN set -e -x; \ | ||
(\ | ||
echo '#!/bin/bash'; \ | ||
echo 'DST=$PWD'; \ | ||
echo 'set -e -x'; \ | ||
echo 'cp -v config/* /glove80-zmk-config/config'; \ | ||
echo 'cd /glove80-zmk-config'; \ | ||
echo 'nix-build config -o combined'; \ | ||
echo 'cp -v combined/glove80.uf2 "$DST/glove80.uf2"'; \ | ||
echo 'chown "$UID:$GID" "$DST/glove80.uf2"'; \ | ||
) > entrypoint.sh; \ | ||
chmod a+x entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
# Run build.sh to use this file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
IMAGE=glove80 | ||
|
||
set -e -x | ||
|
||
docker build -t "$IMAGE" . | ||
docker run --rm -v "$PWD:$PWD" -w "$PWD" -e UID="$(id -u)" -e GID="$(id -g)" "$IMAGE" |