Skip to content

Commit 798d34f

Browse files
committed
Define a docker image based on the nix flake
1 parent 1d2246b commit 798d34f

File tree

7 files changed

+60
-4
lines changed

7 files changed

+60
-4
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
.direnv
3+
target

.envrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This .envrc file is used with direnv to ensure a consistent
2+
# development environment across our team.
3+
4+
set -eu
5+
6+
if type nix >/dev/null 2>&1; then
7+
use flake ./tools/nix
8+
fi
9+
10+
source tools/shell/profile

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*.DS_store
2-
.envrc
32
.direnv
3+
.venv
4+
target
5+
*.so

tools/docker/dev/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM nixos/nix
2+
3+
WORKDIR /autonomy
4+
COPY tools/nix ./tools/nix
5+
6+
RUN nix-channel --update \
7+
&& echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf \
8+
&& nix develop ./tools/nix --command echo "Nix environment built and cached" \
9+
&& mkdir -p /root/.local/bin \
10+
&& mkdir -p /root/.cache
11+
12+
COPY . .
13+
14+
ENTRYPOINT ["nix", "develop", "./tools/nix", "--command"]
15+
CMD ["bash", "-c", "source ./tools/shell/profile && exec bash"]

tools/nix/flake.lock

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

tools/nix/flake.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@
1515
devShells = forEachSupportedSystem ({ pkgs, system }: {
1616
default = pkgs.mkShell {
1717
nativeBuildInputs = with pkgs; [
18+
git
19+
gnumake
1820
commitlint
1921
eclint
22+
uv
23+
python312
24+
rustc
25+
cargo
26+
rustfmt
27+
clippy
2028
];
2129
};
2230
});

tools/shell/profile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
for tool in commitlint eclint uv; do
4+
if ! type "$tool" >/dev/null 2>&1; then
5+
echo "Error: $tool is not set up." >&2
6+
exit 1
7+
fi
8+
done
9+
10+
if [ ! -d ".venv" ]; then
11+
uv venv --python python3.12
12+
source .venv/bin/activate
13+
pushd source/python
14+
uv sync --active
15+
popd
16+
fi
17+
18+
source .venv/bin/activate

0 commit comments

Comments
 (0)