chore: format with alejandra

This commit is contained in:
steveej 2023-02-07 18:24:28 +01:00
parent 05f0cbdfb4
commit 89f5f65f2d
181 changed files with 2720 additions and 2560 deletions

View file

@ -1,7 +1,5 @@
# posh makes use of podman to run an encapsulated shell session
{ pkgs, ... }:
let
{pkgs, ...}: let
cniConfigDir = let
loopback = pkgs.writeText "00-loopback.conf" ''
{
@ -37,12 +35,13 @@ let
]
}
'';
in pkgs.runCommand "cniConfig" { } ''
set -x
mkdir $out;
ln -s ${loopback} $out/${loopback.name}
ln -s ${podman-bridge} $out/${podman-bridge.name}
'';
in
pkgs.runCommand "cniConfig" {} ''
set -x
mkdir $out;
ln -s ${loopback} $out/${loopback.name}
ln -s ${podman-bridge} $out/${podman-bridge.name}
'';
podmanConfig = pkgs.writeText "libpod.conf" ''
# libpod.conf is the default configuration file for all tools using libpod to
@ -125,46 +124,55 @@ let
}
}
'';
in
{
image,
pull ? "always",
global_args ? "",
run_args ? "",
userns ? "keep-id",
}:
(pkgs.writeScriptBin "posh" ''
#! ${pkgs.bash}/bin/bash
source /etc/profile
in { image, pull ? "always", global_args ? "", run_args ? "", userns ? "keep-id"
}:
test -S "$SSH_AUTH_SOCK" && ssh="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK"
tty -s && tty="-t" entrypoint=--entrypoint='["/usr/bin/env","bash","-il"]' || quiet="-q"
(pkgs.writeScriptBin "posh" ''
#! ${pkgs.bash}/bin/bash
source /etc/profile
# define these as variables so we can override them at runtime
POSH_IMAGE=${image}
POSH_PULL=${pull}
test -S "$SSH_AUTH_SOCK" && ssh="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK"
tty -s && tty="-t" entrypoint=--entrypoint='["/usr/bin/env","bash","-il"]' || quiet="-q"
if [ "$1" == "-c" ]; then
# We've most likely been spawned by sshd and are interested in $2 whitch contains the command string
shift
# TODO parse the beginning of the command for POSH_* overrides
fi
# define these as variables so we can override them at runtime
POSH_IMAGE=${image}
POSH_PULL=${pull}
test "$@" && cmd=( -c "$@")
if [ "$1" == "-c" ]; then
# We've most likely been spawned by sshd and are interested in $2 whitch contains the command string
shift
# TODO parse the beginning of the command for POSH_* overrides
fi
test "$@" && cmd=( -c "$@")
HOME_CONTAINERS_CONFIGDIR="$HOME/.config/containers"
HOME_POLICY_JSON="$HOME_CONTAINERS_CONFIGDIR/policy.json"
test -d $HOME_CONTAINERS_CONFIGIDR || mkdir $HOME_CONTAINERS_CONFIGIDR
ln -sf ${policy-json} $HOME_POLICY_JSON
HOME_CONTAINERS_CONFIGDIR="$HOME/.config/containers"
HOME_POLICY_JSON="$HOME_CONTAINERS_CONFIGDIR/policy.json"
test -d $HOME_CONTAINERS_CONFIGIDR || mkdir $HOME_CONTAINERS_CONFIGIDR
ln -sf ${policy-json} $HOME_POLICY_JSON
set -x
exec ${pkgs.podman}/bin/podman \
--cgroup-manager=cgroupfs \
${global_args} \
run \
--annotation=io.crun.keep_original_groups=1 \
--config ${podmanConfig} \
--conmon ${pkgs.conmon}/bin/conmon --runtime ${pkgs.crun}/bin/crun \
--rm -i --network host --pull=''${POSH_PULL} \
$tty $ssh -e HOME -v $HOME:$HOME -w $HOME \
${if userns != null then "--userns=" + userns else ""} \
${run_args} \
''${POSH_IMAGE} /usr/bin/env bash -l "''${cmd[@]}"
'').overrideAttrs (attrs: attrs // { passthru = { shellPath = "/bin/posh"; }; })
set -x
exec ${pkgs.podman}/bin/podman \
--cgroup-manager=cgroupfs \
${global_args} \
run \
--annotation=io.crun.keep_original_groups=1 \
--config ${podmanConfig} \
--conmon ${pkgs.conmon}/bin/conmon --runtime ${pkgs.crun}/bin/crun \
--rm -i --network host --pull=''${POSH_PULL} \
$tty $ssh -e HOME -v $HOME:$HOME -w $HOME \
${
if userns != null
then "--userns=" + userns
else ""
} \
${run_args} \
''${POSH_IMAGE} /usr/bin/env bash -l "''${cmd[@]}"
'')
.overrideAttrs (attrs: attrs // {passthru = {shellPath = "/bin/posh";};})