2021-04-02 01:39:01 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
{ pkgs, ... }:
|
|
|
|
let
|
2022-04-09 19:17:32 +00:00
|
|
|
origImageArgs = builtins.fromJSON (builtins.readFile ./image.json);
|
2021-04-02 01:39:01 +00:00
|
|
|
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;
|
2022-03-24 22:20:56 +00:00
|
|
|
diskSize = 9216;
|
2021-04-02 01:39:01 +00:00
|
|
|
runAsRoot = ''
|
|
|
|
#!{pkgs.runtimeShell}
|
2022-03-13 00:24:57 +00:00
|
|
|
cat <<"EOF" >/sshd_ca.pub
|
|
|
|
${builtins.readFile ../../../ops/secrets/client-ca.pub}
|
|
|
|
EOF
|
2021-04-02 01:39:01 +00:00
|
|
|
cat <<"EOF" >/assets/wrapper_wrapper
|
2021-04-02 02:08:40 +00:00
|
|
|
#!/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
|
2022-03-13 00:24:57 +00:00
|
|
|
/usr/bin/cat <<"EOC" >>/assets/sshd_config
|
|
|
|
TrustedUserCAKeys /sshd_ca.pub
|
|
|
|
Match User git
|
|
|
|
AuthorizedPrincipalsCommandUser root
|
|
|
|
AuthorizedPrincipalsCommand /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-authorized-principals-check lukegb lukegb
|
|
|
|
Match User hg
|
|
|
|
AuthorizedPrincipalsCommandUser root
|
|
|
|
AuthorizedPrincipalsCommand /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-authorized-principals-check lukegb lukegb
|
|
|
|
EOC
|
2021-04-02 02:08:40 +00:00
|
|
|
exec /assets/wrapper "$@"
|
2021-04-02 01:39:01 +00:00
|
|
|
EOF
|
|
|
|
chmod ugo=rx /assets/wrapper_wrapper
|
|
|
|
'';
|
|
|
|
config.Cmd = ["/assets/wrapper_wrapper"];
|
|
|
|
} // {
|
2022-04-09 19:17:32 +00:00
|
|
|
meta = { inherit name tag origImage; };
|
2021-04-02 01:39:01 +00:00
|
|
|
}
|