From 352a0ed5e1c1fde52bd1bf980ab4ba8d0a7805e8 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 28 Nov 2019 01:02:39 +0100 Subject: [PATCH] nix/overlay: add posh and use podman/conman from master --- nix/overlay.nix | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index c0316ce..f8864df 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -23,15 +23,9 @@ in { ''; }; - - - podman = nixpkgs-master.podman; - conmon = nixpkgs-master.conmon; - duplicacy = super.callPackage ./pkgs/duplicacy {}; just = super.callPackage ./pkgs/just.nix {}; mfcl3770cdw = super.callPackage ./pkgs/mfcl3770cdw.nix {}; - slirp4netns = super.callPackage ./pkgs/slirp4netns.nix {}; staruml = super.callPackage ./pkgs/staruml.nix { inherit (super.gnome2) GConf; libgcrypt = super.libgcrypt_1_5; }; roxterm = super.stdenv.mkDerivation { @@ -76,4 +70,35 @@ in { facetimehd-firmware = super.hello; qtile = nixpkgs-master.qtile; + + inherit (nixpkgs-master) podman conmon slirp4netns; + + # posh makes use of podman to run an encapsulated shell session + posh = { image, pull ? "always", global_args ? "", run_args ? "" }: + (super.writeScriptBin "posh" '' + #! ${super.bash}/bin/bash + source /etc/profile + + tty -s && tty="-t" || quiet="-q" + + POSH_IMAGE=${image} + POSH_PULL=${pull} + + if [ "$1" == "-c" ]; then + # we've most likely been spawned by sshd + # $2 contains the command string + shift + # TODO: make the variables overridable via the command_string + fi + + exec ${self.podman}/bin/podman \ + ${global_args} run --rm -i $tty -v ~/:/root -w /root --pull=always --network host --pull=''${POSH_PULL} \ + ${run_args} ''${POSH_IMAGE} $@ + '') + .overrideAttrs(attrs: attrs // { + passthru = { + shellPath = "/bin/posh"; + }; + }); + }