-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate
More file actions
executable file
·42 lines (33 loc) · 1.08 KB
/
generate
File metadata and controls
executable file
·42 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
set -euo pipefail
output_dir="$1"
mkdir -p "$output_dir"
cat >"$output_dir/build.Dockerfile" <<'EOF'
ARG base_image
FROM ${base_image}
ARG user_id
USER root
RUN mkdir -p /nix && chmod 755 /nix
RUN curl -fsSL https://install.determinate.systems/nix | \
sh -s -- install linux \
--no-confirm \
--init none \
--extra-conf "sandbox = false" \
${NIX_VERSION:+--nix-package-url "https://releases.nixos.org/nix/nix-${NIX_VERSION}/nix-${NIX_VERSION}-$(uname -m)-linux.tar.xz"}
# ENV PATH="/nix/var/nix/profiles/default/bin:\${PATH}"
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
# Enable flakes
RUN /bin/mkdir -p /etc/nix && echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf
RUN chown -R ${CNB_USER_ID}:${CNB_GROUP_ID} /nix
USER ${user_id}
EOF
BUILDPACK_ID="renku_nix-packages"
LAYER_NAME="nix-packages"
LAYER_PATH="/layers/${BUILDPACK_ID}/${LAYER_NAME}/nix/store"
cat >"$output_dir/run.Dockerfile" <<EOF
ARG base_image
FROM \${base_image}
USER root
RUN mkdir -p /nix && ln -sf ${LAYER_PATH} /nix/store
USER \${CNB_USER_ID}
EOF