feat: introduce treefmt and fmt all
This commit is contained in:
parent
80250b0179
commit
27c6c4f9fa
237 changed files with 5440 additions and 5214 deletions
|
@ -1,42 +1,44 @@
|
|||
# posh makes use of podman to run an encapsulated shell session
|
||||
{pkgs, ...}: let
|
||||
cniConfigDir = let
|
||||
loopback = pkgs.writeText "00-loopback.conf" ''
|
||||
{
|
||||
"cniVersion": "0.3.0",
|
||||
"type": "loopback"
|
||||
}
|
||||
'';
|
||||
|
||||
podman-bridge = pkgs.writeText "87-podman-bridge.conflist" ''
|
||||
{
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
cniConfigDir =
|
||||
let
|
||||
loopback = pkgs.writeText "00-loopback.conf" ''
|
||||
{
|
||||
"cniVersion": "0.3.0",
|
||||
"name": "podman",
|
||||
"plugins": [
|
||||
{
|
||||
"type": "bridge",
|
||||
"bridge": "cni0",
|
||||
"isGateway": true,
|
||||
"ipMasq": true,
|
||||
"ipam": {
|
||||
"type": "host-local",
|
||||
"subnet": "10.88.0.0/16",
|
||||
"routes": [
|
||||
{ "dst": "0.0.0.0/0" }
|
||||
]
|
||||
"type": "loopback"
|
||||
}
|
||||
'';
|
||||
|
||||
podman-bridge = pkgs.writeText "87-podman-bridge.conflist" ''
|
||||
{
|
||||
"cniVersion": "0.3.0",
|
||||
"name": "podman",
|
||||
"plugins": [
|
||||
{
|
||||
"type": "bridge",
|
||||
"bridge": "cni0",
|
||||
"isGateway": true,
|
||||
"ipMasq": true,
|
||||
"ipam": {
|
||||
"type": "host-local",
|
||||
"subnet": "10.88.0.0/16",
|
||||
"routes": [
|
||||
{ "dst": "0.0.0.0/0" }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "portmap",
|
||||
"capabilities": {
|
||||
"portMappings": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "portmap",
|
||||
"capabilities": {
|
||||
"portMappings": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
'';
|
||||
in
|
||||
pkgs.runCommand "cniConfig" {} ''
|
||||
]
|
||||
}
|
||||
'';
|
||||
in
|
||||
pkgs.runCommand "cniConfig" { } ''
|
||||
set -x
|
||||
mkdir $out;
|
||||
ln -s ${loopback} $out/${loopback.name}
|
||||
|
@ -125,54 +127,58 @@
|
|||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
image,
|
||||
pull ? "always",
|
||||
global_args ? "",
|
||||
run_args ? "",
|
||||
userns ? "keep-id",
|
||||
}:
|
||||
(pkgs.writeScriptBin "posh" ''
|
||||
#! ${pkgs.bash}/bin/bash
|
||||
source /etc/profile
|
||||
{
|
||||
image,
|
||||
pull ? "always",
|
||||
global_args ? "",
|
||||
run_args ? "",
|
||||
userns ? "keep-id",
|
||||
}:
|
||||
(pkgs.writeScriptBin "posh" ''
|
||||
#! ${pkgs.bash}/bin/bash
|
||||
source /etc/profile
|
||||
|
||||
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"
|
||||
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"
|
||||
|
||||
# define these as variables so we can override them at runtime
|
||||
POSH_IMAGE=${image}
|
||||
POSH_PULL=${pull}
|
||||
# define these as variables so we can override them at runtime
|
||||
POSH_IMAGE=${image}
|
||||
POSH_PULL=${pull}
|
||||
|
||||
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
|
||||
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 "$@")
|
||||
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";
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue