From 3dd055b640e67db4a0defceddfe6cfe025922405 Mon Sep 17 00:00:00 2001 From: noe Date: Tue, 22 Apr 2025 12:04:25 -0700 Subject: [PATCH 1/2] plugins still can't inline huh --- examples/quickstart/default.nix | 3 ++- examples/quickstart/pluginTests.doll | 7 ++++++- examples/quickstart/plugins/inline-example.sh | 13 ------------- examples/{ => quickstart}/plugins/plural.sh | 3 ++- examples/quickstart/plugins/tools.py | 7 +++++++ pkgs/mkMarkdollPlugin.nix | 5 +++++ 6 files changed, 22 insertions(+), 16 deletions(-) delete mode 100755 examples/quickstart/plugins/inline-example.sh rename examples/{ => quickstart}/plugins/plural.sh (82%) create mode 100755 examples/quickstart/plugins/tools.py diff --git a/examples/quickstart/default.nix b/examples/quickstart/default.nix index ba559ec..bd763e0 100644 --- a/examples/quickstart/default.nix +++ b/examples/quickstart/default.nix @@ -12,6 +12,7 @@ # can do an [invoke(plural)(...):yay!] type thing # one can invoke stuff inline too without doing this. markdollPlugins = [ - (mkMarkdollPlugin "plural" ../plugins/plural.sh) + (mkMarkdollPlugin "plural" ./plugins/plural.sh) + (mkMarkdollPlugin "tools" ./plugins/tools.py) ]; } \ No newline at end of file diff --git a/examples/quickstart/pluginTests.doll b/examples/quickstart/pluginTests.doll index e270d45..d5c9aa3 100644 --- a/examples/quickstart/pluginTests.doll +++ b/examples/quickstart/pluginTests.doll @@ -4,4 +4,9 @@ title: plugin tests &plural plugin [invoke(plural)(aki):hi this one is aki] - [invoke(plural)(noe):hi this one is noe] \ No newline at end of file + + [invoke(plural)(noe):hi this one is noe] + + hellorld [invoke(tools)(flip):hellorld] + + dolldolldoll|llodllodllod [invoke(tools)(flip):dolldolldoll|llodllodllod] \ No newline at end of file diff --git a/examples/quickstart/plugins/inline-example.sh b/examples/quickstart/plugins/inline-example.sh deleted file mode 100755 index 896824c..0000000 --- a/examples/quickstart/plugins/inline-example.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -flip() { - LC_ALL=C LC_ALL=en_US.UTF-8 rev <"/dev/stdin" -} - -main() { - case $1 in - flip) flip;; - esac -} - -main $1 \ No newline at end of file diff --git a/examples/plugins/plural.sh b/examples/quickstart/plugins/plural.sh similarity index 82% rename from examples/plugins/plural.sh rename to examples/quickstart/plugins/plural.sh index 4b33135..f77f8ae 100755 --- a/examples/plugins/plural.sh +++ b/examples/quickstart/plugins/plural.sh @@ -1,6 +1,7 @@ #!/bin/sh alterName=$1 +message=$(<"/dev/stdin") cat << EOF
@@ -8,7 +9,7 @@ cat << EOF ${alterName}@41666$>  - $(<"/dev/stdin") + ${message}
EOF \ No newline at end of file diff --git a/examples/quickstart/plugins/tools.py b/examples/quickstart/plugins/tools.py new file mode 100755 index 0000000..a07155c --- /dev/null +++ b/examples/quickstart/plugins/tools.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys + +if sys.argv[1] == "flip": + stdin = sys.stdin.read() + print(stdin[::-1], flush=True) \ No newline at end of file diff --git a/pkgs/mkMarkdollPlugin.nix b/pkgs/mkMarkdollPlugin.nix index 32a3483..c29673b 100644 --- a/pkgs/mkMarkdollPlugin.nix +++ b/pkgs/mkMarkdollPlugin.nix @@ -2,6 +2,11 @@ inherit name src; version = "0.0.0"; dontUnpack = true; + + buildInputs = [ + pkgs.python3 + ]; + installPhase = " mkdir -p $out/bin cp $src $out/bin/${name} From a17d82f9961be678784262a92c50cac11b66dae6 Mon Sep 17 00:00:00 2001 From: noe Date: Tue, 22 Apr 2025 12:08:25 -0700 Subject: [PATCH 2/2] plugins can have dependencies --- examples/quickstart/default.nix | 2 +- pkgs/mkMarkdollPlugin.nix | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/quickstart/default.nix b/examples/quickstart/default.nix index bd763e0..c5bda29 100644 --- a/examples/quickstart/default.nix +++ b/examples/quickstart/default.nix @@ -13,6 +13,6 @@ # one can invoke stuff inline too without doing this. markdollPlugins = [ (mkMarkdollPlugin "plural" ./plugins/plural.sh) - (mkMarkdollPlugin "tools" ./plugins/tools.py) + ((mkMarkdollPlugin "tools" ./plugins/tools.py).override { buildInputs = [ pkgs.python3 ]; }) ]; } \ No newline at end of file diff --git a/pkgs/mkMarkdollPlugin.nix b/pkgs/mkMarkdollPlugin.nix index c29673b..08524e0 100644 --- a/pkgs/mkMarkdollPlugin.nix +++ b/pkgs/mkMarkdollPlugin.nix @@ -1,14 +1,13 @@ -{ pkgs }: name: src: pkgs.stdenvNoCC.mkDerivation { - inherit name src; - version = "0.0.0"; - dontUnpack = true; +{ pkgs }: name: src: let + drv = { buildInputs ? [], }: pkgs.stdenvNoCC.mkDerivation { + inherit name src buildInputs; + + version = "0.0.0"; + dontUnpack = true; - buildInputs = [ - pkgs.python3 - ]; - - installPhase = " - mkdir -p $out/bin - cp $src $out/bin/${name} - "; -} \ No newline at end of file + installPhase = " + mkdir -p $out/bin + cp $src $out/bin/${name} + "; + }; +in pkgs.lib.customisation.makeOverridable drv { buildInputs = []; } \ No newline at end of file