mirror of
https://github.com/RGBCube/HTMNIX
synced 2025-07-26 15:37:46 +00:00
Use getEnv to evaulate any file
This commit is contained in:
parent
730e3eb8f0
commit
5e91f5fa6f
4 changed files with 45 additions and 1 deletions
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
*
|
||||||
|
|
||||||
|
!site/
|
||||||
|
|
||||||
|
!.gitignore
|
||||||
|
!flake.lock
|
||||||
|
|
||||||
|
!*.nix
|
||||||
|
!*.sh
|
32
build.sh
Executable file
32
build.sh
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e # Fail fast.
|
||||||
|
|
||||||
|
rm -rf _site
|
||||||
|
|
||||||
|
# Creates all dirs needed.
|
||||||
|
for dir in $(find site -type d); do
|
||||||
|
mkdir -p "_$dir"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$HTMNIX_LOCAL" == 1 ]]; then
|
||||||
|
FLAKE_REF=.
|
||||||
|
else
|
||||||
|
FLAKE_REF=github:RGBCube/HTMNIX
|
||||||
|
fi
|
||||||
|
|
||||||
|
for file in $(find site -type f); do
|
||||||
|
if [[ ! "$file" =~ ^_ ]]; then
|
||||||
|
if [[ "$file" =~ .nix$ ]]; then
|
||||||
|
echo "Processing file $file to _${file%.nix}.html..."
|
||||||
|
TARGET_FILE="$file" nix eval "$FLAKE_REF#result" --apply toString --raw > "_${file%.nix}.html"
|
||||||
|
echo "Done!"
|
||||||
|
else
|
||||||
|
echo "Copying file $file to _$file..."
|
||||||
|
cp "$file" "_$file"
|
||||||
|
echo "Done!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All done!"
|
|
@ -74,6 +74,9 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
result = builtins.scopedImport { inherit (self) raw __findFile; } ./html.nix;
|
result = let
|
||||||
|
targetFile = builtins.getEnv "TARGET_FILE";
|
||||||
|
targetFile' = if targetFile != "" then targetFile else "site/index.nix";
|
||||||
|
in builtins.scopedImport { inherit (self) raw __findFile; } ./${targetFile'};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue