Skip to content

Instantly share code, notes, and snippets.

@leshy
Last active December 14, 2024 08:34
Show Gist options
  • Select an option

  • Save leshy/a501edb6809ecb43681d7ed76684a81c to your computer and use it in GitHub Desktop.

Select an option

Save leshy/a501edb6809ecb43681d7ed76684a81c to your computer and use it in GitHub Desktop.
diagon org mode babel language
(defun org-babel-execute:diagon (body params)
(let* ((mode (or (cdr (assoc :mode params))
(error "You must specify a :mode parameter")))
(diagon-command (format "nix run github:petertrotman/nixpkgs/Diagon#diagon -- %s -style=Unicode" mode))
(result-type (cdr (assoc :result-type params)))
(output (string-trim (org-babel-eval diagon-command body))))
(if (eq result-type 'value)
output
(org-babel-import-elisp-from-file output))))
pot_outlet -> container -> pump -> water_sink
container -> sensor
controller -> sensor
controller -> pump
┌──────────┐┌──────────┐
│pot_outlet││controller│
└┬─────────┘└┬┬────────┘
┌▽────────┐  ││         
│container│  ││         
└───┬────┬┘  ││         
    │    │  ┌│┘         
   ┌│────│──│┘          
┌──▽▽┐┌──▽──▽┐          
│pump││sensor│          
└┬───┘└──────┘          
┌▽─────────┐            
│water_sink│            
└──────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment