fix character escaping in nixos-deploy
This commit is contained in:
parent
79a2576dfd
commit
1ebbb7937d
1 changed files with 101 additions and 104 deletions
|
|
@ -1,22 +1,20 @@
|
||||||
{ lib
|
{
|
||||||
, stdenv
|
lib,
|
||||||
, nixos-rebuild
|
stdenv,
|
||||||
, openssh
|
nixos-rebuild,
|
||||||
, coreutils
|
openssh,
|
||||||
, gnugrep
|
coreutils,
|
||||||
, gawk
|
gnugrep,
|
||||||
|
gawk,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "nixos-deploy";
|
pname = "nixos-deploy";
|
||||||
version = "1.0";
|
version = "1.0";
|
||||||
|
|
||||||
src = lib.fakeSha256; # will be ignored since we're using `installPhase`
|
src = null;
|
||||||
|
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
|
|
||||||
buildInputs = [ ];
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cat > $out/bin/nixos-deploy << 'EOF'
|
cat > $out/bin/nixos-deploy << 'EOF'
|
||||||
|
|
@ -91,10 +89,10 @@ if [[ -z "$TARGET_HOST" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$TARGET_HOST" == *"@"* ]]; then
|
if [[ "$TARGET_HOST" == *"@"* ]]; then
|
||||||
SSH_USER="${TARGET_HOST%@*}"
|
SSH_USER="''${TARGET_HOST%@*}"
|
||||||
SSH_HOST="${TARGET_HOST#*@}"
|
SSH_HOST="''${TARGET_HOST#*@}"
|
||||||
else
|
else
|
||||||
SSH_USER="$("${coreutils}/bin/whoami")"
|
SSH_USER="$("''${coreutils}/bin/whoami")"
|
||||||
SSH_HOST="$TARGET_HOST"
|
SSH_HOST="$TARGET_HOST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -104,7 +102,7 @@ if [[ "$LOCAL_BUILD" != "true" ]]; then
|
||||||
GC_ROOT_PATH="/tmp/nixos-deploy-$SSH_HOST-$$"
|
GC_ROOT_PATH="/tmp/nixos-deploy-$SSH_HOST-$$"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
REBUILD_CMD="${nixos-rebuild}/bin/nixos-rebuild $ACTION --flake $FLAKE_URI --target-host $TARGET_HOST"
|
REBUILD_CMD="''${nixos-rebuild}/bin/nixos-rebuild $ACTION --flake $FLAKE_URI --target-host $TARGET_HOST"
|
||||||
|
|
||||||
if [[ "$LOCAL_BUILD" == "true" ]]; then
|
if [[ "$LOCAL_BUILD" == "true" ]]; then
|
||||||
echo -e "Building locally and deploying to remote host"
|
echo -e "Building locally and deploying to remote host"
|
||||||
|
|
@ -121,14 +119,13 @@ fi
|
||||||
echo -e "Running: $REBUILD_CMD"
|
echo -e "Running: $REBUILD_CMD"
|
||||||
exec $REBUILD_CMD
|
exec $REBUILD_CMD
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x $out/bin/nixos-deploy
|
chmod +x $out/bin/nixos-deploy
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Tool to deploy a NixOS flake to a remote host using nixos-rebuild";
|
description = "Tool to deploy a NixOS flake to a remote host using nixos-rebuild";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ ];
|
|
||||||
platforms = platforms.unix;
|
platforms = platforms.unix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue