depot/nix/docker/heptapod/default.nix

37 lines
1.2 KiB
Nix

# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0
{ pkgs, ... }:
let
origImageArgs = {
imageName = "octobus/heptapod";
imageDigest = "sha256:22658ace9a2f0e95db80b2577b76c82c9f961ca9b3995eeac5cf6f306b9f2fa8";
sha256 = "sha256:1n0dclr5fd4s2l3rrs67m4dw51zzja3x7n0bz2qi5f8avpzzfr9f";
finalImageName = "octobus/heptapod";
finalImageTag = "0.28.2";
};
origImage = pkgs.dockerTools.pullImage origImageArgs;
name = origImageArgs.imageName;
tag = "${origImageArgs.finalImageTag}-lukegb";
in pkgs.dockerTools.buildImage rec {
inherit name tag;
fromImage = origImage;
fromImageName = origImageArgs.finalImageName;
fromImageTag = origImageArgs.finalImageTag;
diskSize = 8192;
runAsRoot = ''
#!{pkgs.runtimeShell}
cat <<"EOF" >/assets/wrapper_wrapper
#!/bin/bash
/usr/bin/id hg || /usr/sbin/useradd -g $(id -u git) -u $(id -g git) -o -d /var/opt/gitlab -p "*" hg
/usr/bin/grep "AllowUsers git hg" /assets/sshd_config || /bin/sed -i "s/AllowUsers git/AllowUsers git hg/" /assets/sshd_config
exec /assets/wrapper "$@"
EOF
chmod ugo=rx /assets/wrapper_wrapper
'';
config.Cmd = ["/assets/wrapper_wrapper"];
} // {
meta = { inherit name tag; };
}