Lots of updates - restructured, added things...
This commit is contained in:
@@ -5,15 +5,15 @@
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# Sub-projects: uncomment and replace URLs when ready
|
||||
# project-a = {
|
||||
# url = "path:/path/to/project-a";
|
||||
# inputs.nixpkgs.follows = "nixpkgs";
|
||||
# };
|
||||
# project-b = {
|
||||
# url = "path:/path/to/project-b";
|
||||
# inputs.nixpkgs.follows = "nixpkgs";
|
||||
# };
|
||||
word-embedding-golf = {
|
||||
url = "github:anerisgreat/word-embedding-golf";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
ar-globe-explorer = {
|
||||
url = "github:anerisgreat/ar-world-border-viewer";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... } @ inputs:
|
||||
@@ -21,9 +21,9 @@
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
# Sub-project outputs — uncomment when inputs above are added
|
||||
# subProjectA = inputs.project-a.packages.${system}.default;
|
||||
# subProjectB = inputs.project-b.packages.${system}.default;
|
||||
wordEmbeddingGolfPkg = inputs.word-embedding-golf.packages.${system}.default;
|
||||
|
||||
arGlobeExplorerPkg = inputs.ar-globe-explorer.packages.${system}.default;
|
||||
|
||||
site = pkgs.stdenv.mkDerivation {
|
||||
name = "personal-site";
|
||||
@@ -40,9 +40,19 @@
|
||||
installPhase = ''
|
||||
cp -r public/. $out/
|
||||
|
||||
# Sub-project integration: when adding a sub-project, add lines like:
|
||||
# mkdir -p $out/project-a
|
||||
# cp -r <subProjectA-store-path>/. $out/project-a/
|
||||
mkdir -p $out/word-embedding-golf
|
||||
cp -r ${wordEmbeddingGolfPkg}/. $out/word-embedding-golf/
|
||||
|
||||
mkdir -p $out/ar-globe-explorer
|
||||
cp -r ${arGlobeExplorerPkg}/. $out/ar-globe-explorer/
|
||||
|
||||
# Inject a "back to site" banner into all sub-project HTML pages
|
||||
BANNER='<div id="back-banner" style="position:fixed;top:0;left:0;right:0;padding:.4rem 1rem;background:rgba(0,0,0,.82);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);z-index:9999;font-family:-apple-system,BlinkMacSystemFont,sans-serif;font-size:.82rem;border-bottom:1px solid rgba(255,255,255,.08);"><a href="/" style="color:#93c5fd;text-decoration:none;font-weight:500;">← aner.zakobar.com</a></div>'
|
||||
for dir in $out/word-embedding-golf $out/ar-globe-explorer; do
|
||||
find "$dir" -name "*.html" | while IFS= read -r f; do
|
||||
sed -i -E "s|<body([^>]*)>|<body\1>$BANNER|" "$f"
|
||||
done
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -95,6 +105,47 @@
|
||||
'';
|
||||
};
|
||||
|
||||
new-thing = pkgs.writeShellApplication {
|
||||
name = "new-thing";
|
||||
runtimeInputs = [ pkgs.coreutils pkgs.gnused ];
|
||||
excludeShellChecks = [ "SC2001" ];
|
||||
text = ''
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: new-thing \"Title\" \"flake-url\" \"Short description\""
|
||||
exit 1
|
||||
fi
|
||||
title="$1"
|
||||
flake_url="$2"
|
||||
desc="$3"
|
||||
slug=$(echo "$title" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//;s/-$//')
|
||||
camel=$(echo "$slug" | sed 's/-\([a-z]\)/\u\1/g')
|
||||
filename="things/''${slug}.org"
|
||||
mkdir -p things
|
||||
cat > "$filename" <<EOF
|
||||
#+THINGS_TITLE: $title
|
||||
#+THINGS_DESC: $desc
|
||||
#+THINGS_PATH: $slug
|
||||
#+THINGS_FLAKE: $flake_url
|
||||
EOF
|
||||
echo "Created: $filename"
|
||||
echo ""
|
||||
echo "Add to flake.nix inputs:"
|
||||
echo " ''${slug} = {"
|
||||
echo " url = \"$flake_url\";"
|
||||
echo " inputs.nixpkgs.follows = \"nixpkgs\";"
|
||||
echo " };"
|
||||
echo ""
|
||||
echo "Add let binding before 'site =':"
|
||||
echo " ''${camel}Pkg = inputs.''${slug}.packages.\''${system}.default;"
|
||||
echo ""
|
||||
echo "Add to installPhase after 'cp -r public/. \$out/':"
|
||||
echo " mkdir -p \$out/''${slug}"
|
||||
echo " cp -r \''${''${camel}Pkg}/. \$out/''${slug}/"
|
||||
echo ""
|
||||
echo "Then run: nix flake lock"
|
||||
'';
|
||||
};
|
||||
|
||||
new-post = pkgs.writeShellApplication {
|
||||
name = "new-post";
|
||||
runtimeInputs = [ pkgs.coreutils pkgs.gnused ];
|
||||
@@ -123,7 +174,7 @@ EOF
|
||||
packages.default = site;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [ new-post ];
|
||||
packages = [ new-post new-thing ];
|
||||
};
|
||||
|
||||
apps = {
|
||||
|
||||
Reference in New Issue
Block a user