Hi all,
i want to setup revealjs in a flake. i am following the full setup mentioned here:
To check if directory path is already there i use
if builtins.pathExists (builtins.toString ./path)
then "echo isthere"
else "echo bummer";
but this always prints “bummer”. why?
if i do
nix-instantiate --eval -E 'builtins.pathExists (builtins.toString ./path)';
it prints true, is the flake environment different?
what am i trying to do?
i need to clone the repo which i do with fetchFromGithub
and then i want to do a npm install
& npm start
.
my idea was to use buildinputs and copy over the files in the shellHook.
cp $buildInputs ./.
This however should only happen once. for all nix develop
after that it should check if the path is not already there.
case 1(initial setup):
shellHook which copies over the buildinputs and does npm install&npm start
case 2 (case 1 was executed before):
check if a directory from buildinputs is already there, check if node_modules are already there, do npm start
flake:
{
description = "revealjs flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
revealjs = {
url = "github:hakimel/reveal.js";
flake = false;
};
};
outputs = inputs @ {
self,
nixpkgs,
revealjs,
}: let
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
revealjs = pkgs.fetchFromGitHub {
owner = "hakimel";
repo = "reveal.js";
rev = "2927be34d83bc0f0552867092272390ae951a715";
hash = "sha256-dZDRmOAlCAKRrQtlf5p5DqMK+LciMIBVkSugcRvObUY=";
};
in {
devShells.aarch64-darwin.default = let
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
in
pkgs.mkShell {
packages = with pkgs; [nodejs openssl];
buildInputs = [revealjs];
shellHook =
if builtins.pathExists (builtins.toString ./path)
then "echo isthere"
else "echo bummer";
};
};
}
Am i on the right track or is there a better way?