Skip to content

Commit

Permalink
editors/nvim: fix missing example folder issue in remote testing (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruixi-rebirth authored Apr 24, 2024
2 parents a9a1fc3 + d22b915 commit ba9f66a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
16 changes: 16 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 29 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

flake-parts.url = "github:hercules-ci/flake-parts";

flake-root.url = "github:srid/flake-root";
};

outputs = { nixpkgs, flake-parts, ... }@inputs: flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.flake-root.flakeModule
];
perSystem = { config, self', inputs', pkgs, system, ... }:
with pkgs;
Expand Down Expand Up @@ -50,13 +53,36 @@
nativeBuildInputs = [
nixd
pkgs.nixpkgs-fmt
pkgs.git
(import ./nixd/docs/editors/nvim-lsp.nix { inherit pkgs; })
];
inputsFrom = [
config.flake-root.devShell
];
shellHook = ''
echo -e "\n\033[1;31mDuring the first time nixd launches, the flake inputs will be fetched from the internet, this is rather slow.\033[0m"
echo -e "\033[1;34mEntering the nvim test environment...\033[0m"
mkdir -p /tmp/NixOS_Home-Manager
cp -r ./nixd/docs/examples/NixOS_Home-Manager/* /tmp/NixOS_Home-Manager/
cd /tmp/NixOS_Home-Manager
cd $FLAKE_ROOT
export GIT_REPO=https://github.com/nix-community/nixd.git
export EXAMPLES_PATH=nixd/docs/examples
export WORK_TEMP=/tmp/NixOS_Home-Manager
if [ -d "$WORK_TEMP" ]; then
rm -rf $WORK_TEMP
fi
mkdir -p $WORK_TEMP
cp -r $EXAMPLES_PATH/NixOS_Home-Manager/* $WORK_TEMP/ 2>/dev/null
if [[ $? -ne 0 ]]; then
export GIT_DIR=$WORK_TEMP/.git
export GIT_WORK_TREE=/tmp/NixOS_Home-Manager
git init
git config core.sparseCheckout true
git remote add origin $GIT_REPO
echo "$EXAMPLES_PATH/NixOS_Home-Manager/" >$GIT_DIR/info/sparse-checkout
git pull origin main
cp $GIT_WORK_TREE\/$EXAMPLES_PATH/NixOS_Home-Manager/* $GIT_WORK_TREE 2>/dev/null
rm -rf $GIT_WORK_TREE/nixd
fi
cd $WORK_TEMP
echo -e "\033[1;32mNow, you can edit the nix file by running the following command:\033[0m"
echo -e "\033[1;33m'nvim-lsp flake.nix'\033[0m"
echo -e "\033[1;34mEnvironment setup complete.\033[0m"
Expand Down

0 comments on commit ba9f66a

Please sign in to comment.