├── SiteCompiler.hs ├── _site └── index.html ├── ci.nix ├── dhall.nix ├── execline-vs-bash.nix ├── getMeta.hs ├── imports.nix ├── markdown-to-html ├── Main.hs ├── Setup.hs └── markdown-to-html.cabal ├── notes ├── blog-requirements.org ├── dhall-cheatsheet.md ├── execline │ ├── default.nix │ └── execline-vs-bash.dhall ├── literate-devops-with-emacs.org ├── mail-requirements.org ├── minimal-ember-and-nix-project.md ├── nix-as-root-on-debian.org ├── purescript-resources.md ├── rust-string-conversions.md ├── scala-misc.org └── sockets.org ├── package.yaml ├── posts ├── ligature-emulation-in-emacs │ └── post.md ├── nixos-on-lit-2017 │ ├── post.md │ ├── poster.jpg │ └── programm.png └── wip │ └── how-i-develop-with-nix.md ├── src └── Text │ └── Pandoc │ └── FromMeta.hs ├── talks └── nix │ ├── functional-aspects.html │ ├── img │ ├── nix-derivations-2.svg │ ├── nix-derivations.svg │ ├── nix-derivations.xml │ ├── nix-diagrams.xml │ ├── nix-stack.png │ ├── nix-stack.svg │ ├── nixos-hex.svg │ ├── nixos.png │ ├── package-manager-nix.svg │ └── package-manager-old.svg │ ├── init.sh │ ├── intro-to-nixos.html │ ├── nixpkgs-tests │ ├── index.html │ └── style.css │ └── notes └── templates └── index.html /SiteCompiler.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Profpatsch.Blog.Compiler (compileBlogDefaultMain) 4 | import Development.Shake 5 | 6 | main :: IO () 7 | main = compileBlogDefaultMain 8 | -------------------------------------------------------------------------------- /_site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Profpatsch’s Lair 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |

Profpatsch

21 |

22 | 23 | 26 | 29 |

30 |
31 |
32 | 33 |
34 |
    35 |
  1. 36 |

    Ligature Emulation in Emacs;

    37 |

    Tags: emacs

    38 |
  2. 39 |
  3. 40 |

    Hello, dis is blog post;

    41 |

    Tags: foo

    42 |
  4. 43 |
  5. 44 |

    NixOS at the Linux Infotag;

    45 |

    Tags: nixos

    46 |
  6. 47 | 48 |
49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /ci.nix: -------------------------------------------------------------------------------- 1 | let 2 | inherit (import ./imports.nix) 3 | pkgs vuizvui; 4 | inherit (vuizvui.pkgs.profpatsch) 5 | writeExecline; 6 | 7 | home-dir = 8 | # avoid matching this file 9 | let home = "/" + "home/"; 10 | in writeExecline "check-home-dir" {} [ 11 | "if" [ "${pkgs.git}/bin/git" "grep" home ] 12 | "foreground" [ "echo" "found some files referencing /home!" ] 13 | "exit" "1" 14 | ]; 15 | 16 | in { 17 | inherit home-dir; 18 | } 19 | -------------------------------------------------------------------------------- /dhall.nix: -------------------------------------------------------------------------------- 1 | { system, pkgs, lib }: 2 | 3 | let 4 | dhallPkg = pkgs.dhall; 5 | 6 | # “Pipe” mechanism for nix store files. 7 | # The given file is piped through the command and put into $out. 8 | # Can be chained quite easily. 9 | pipe = 10 | { name # of the derivation 11 | , invocation # list of executable and args 12 | , file # file to pipe in 13 | }: 14 | assert (builtins.isList invocation && invocation != []); 15 | let command = builtins.head invocation; 16 | args = builtins.tail invocation; 17 | in derivation { 18 | builder = pkgs.writeScript "toStdin-builder.sh" '' 19 | #!${pkgs.dash}/bin/dash 20 | <"$file" $command "$@" > $out 21 | ''; 22 | inherit command args file name system; 23 | outputs = [ "out" ]; 24 | }; 25 | 26 | # Pipe a file to the dhall language compiler, save result to $out. 27 | pipeDhall = 28 | { name # of the derivation 29 | , file # file to pipe in 30 | , explain ? false # whether errors should be longform 31 | }: 32 | pipe { 33 | inherit name file; 34 | invocation = [ "${dhallPkg}/bin/dhall" ] 35 | ++ lib.optional explain "--explain"; 36 | }; 37 | 38 | # Save a nix value in a formatted dhall file. 39 | # Uses `toDhallValue`. 40 | toDhallDrv = name: val: 41 | pipe { 42 | inherit name; 43 | invocation = ["${dhallPkg}/bin/dhall-format"]; 44 | file = (pkgs.writeText "${name}-unformatted" 45 | (toDhallValue {} val).rep); 46 | }; 47 | 48 | # Convert a nix value (that doesn’t contain nulls or functions) 49 | # into an unformatted dhall value string (no type annotations). 50 | toDhallValue = {}: v: with builtins; 51 | if isInt v then dhall.unsafe.integer v 52 | else if isBool v then dhall.unsafe.bool v 53 | else if isString v then dhall.unsafe.text v 54 | else if isList v then dhall.unsafe.list (map (toDhallValue {}) v) 55 | else if isAttrs v then dhall.unsafe.record 56 | (lib.mapAttrs (_: val: toDhallValue {} val) v) 57 | # nice? 58 | else if null == v then abort "toDhallValue: null can’t be converted" 59 | else if isFunction v then abort "toDhallValue: functions can’t be converted" 60 | else abort "toDhallValue: should not happen"; 61 | 62 | # Unsafe builders of dhall values. 63 | # Contain their structured form in `.val` 64 | # and their formatted dhall string representations in `.rep`. 65 | # Attention: Recursive values (e.g. list elements) 66 | # must already be structured dhall values! 67 | dhall.unsafe = with builtins; 68 | let val = v: r: { val = v; rep = r; }; 69 | in { 70 | bool = b: val b (if b then "True" else "False"); 71 | natural = n: val n "+${toString n}"; 72 | integer = i: val i (toString i); 73 | # double = 74 | # TODO: escaping 75 | text = t: val t t; 76 | list = l: val l "[${lib.concatMapStringsSep ", " (x: x.rep) l}]"; 77 | optional = o: val o (if o == null 78 | then "[]" 79 | else "[${o.rep}]"); 80 | record = r: val r ("{ " 81 | + lib.concatStringsSep ", " (lib.mapAttrsToList 82 | # TODO: escaping 83 | (name: value: "${toString name} = ${value.rep}") r) 84 | + " }"); 85 | # union = 86 | }; 87 | 88 | 89 | in { inherit pipeDhall toDhallDrv; } 90 | -------------------------------------------------------------------------------- /execline-vs-bash.nix: -------------------------------------------------------------------------------- 1 | let 2 | inherit (import ./imports.nix) 3 | pkgs vuizvui nixperiments dhall-prelude runCommandLocal getBins; 4 | 5 | inherit (vuizvui.pkgs.profpatsch) 6 | runExeclineLocal; 7 | 8 | markdown-to-html = string: 9 | let 10 | exe = pkgs.writers.writeHaskell "markdown-to-html" { 11 | libraries = [ 12 | pkgs.haskellPackages.cmark-gfm 13 | ]; 14 | } (builtins.readFile ./markdown-to-html/Main.hs); 15 | in builtins.readFile 16 | (runExeclineLocal "markdownToHtml" { stdin = string; } [ 17 | "importas" "-iu" "out" "out" 18 | "redirfd" "-w" "1" "$out" 19 | exe 20 | ]); 21 | 22 | execline-vs-bash = import ./notes/execline { inherit pkgs dhall-prelude markdown-to-html runCommandLocal; }; 23 | 24 | in execline-vs-bash 25 | -------------------------------------------------------------------------------- /getMeta.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Control.Monad 4 | import Text.Pandoc.Readers.Markdown 5 | import Text.Pandoc 6 | import Data.Default 7 | import Data.Map as M 8 | import Data.Monoid 9 | 10 | raw :: IO String 11 | raw = readFile "posts/nixos-on-lit-2017/post.md" 12 | 13 | main = putPandoc 14 | 15 | putPandoc = print $ 16 | writeHtmlString def $ Pandoc mempty [Plain $ [Str "foo"]] 17 | 18 | readAndPrintMeta = do 19 | s <- raw 20 | let Right (Pandoc m _) = readMarkdown def s 21 | forM_ (M.toList $ unMeta m) $ \i -> do 22 | putStr $ fst i 23 | putStr ": " 24 | putStrLn .show $ snd i 25 | -------------------------------------------------------------------------------- /imports.nix: -------------------------------------------------------------------------------- 1 | let 2 | vuizvui = import (pkgs.fetchFromGitHub { 3 | owner = "openlab-aux"; 4 | repo = "vuizvui"; 5 | rev = "d9addb8fb3f60ce524c482f3993f04f5114fc41f"; 6 | sha256 = "1l0pjk88vrv6igjwyghg121w3ysvpsq61pr8l9gjaafgqxs56gs0"; 7 | }) { }; 8 | 9 | dhall-simple = import (pkgs.fetchFromGitHub { 10 | owner = "justinwoo"; 11 | repo = "easy-dhall-nix"; 12 | rev = "01844fa08e20fa4460741f40175857d6fd15ae8e"; 13 | sha256 = "07zr7y93hmn6gxqcsjc1db7fc6fhnlc0jwv2snzqsk812ypacbs6"; 14 | }) {}; 15 | 16 | # TODO: sticky pkgs 17 | pkgs = import { 18 | overlays = [ (_: _: { 19 | dhall = dhall-simple.dhall-simple; 20 | dhall-nix = dhall-simple.dhall-nix-simple; 21 | dhall-json = dhall-simple.dhall-json-simple; 22 | }) ]; 23 | }; 24 | 25 | nixperiments = import (pkgs.fetchFromGitHub { 26 | owner = "Profpatsch"; 27 | repo = "nixperiments"; 28 | rev = "adec5d3458dc24a062f2582531208241b2aa61b4"; 29 | sha256 = "07zr7y93hmn6gxqcsjc1db7fc6fhnlc0jwv2s5zqsk812ypacbs6"; 30 | }) { nixpkgs = pkgs; }; 31 | 32 | dhall-prelude = "${pkgs.fetchFromGitHub { 33 | owner = "dhall-lang"; 34 | repo = "dhall-lang"; 35 | rev = "084ec169695c09e8ac92c4c0dfeb4f9b8188b593"; 36 | sha256 = "12x4qkhx15cj6zq6m7v943blnncaqh8bsq4i3276l2zbngv499rd"; 37 | }}/Prelude"; 38 | 39 | runCommandLocal = name: args: cmd: 40 | pkgs.runCommand name (args // { 41 | preferLocalBuild = true; 42 | allowSubstitutes = false; 43 | }) cmd; 44 | 45 | 46 | in { 47 | inherit pkgs vuizvui nixperiments 48 | dhall-simple dhall-prelude 49 | runCommandLocal; 50 | } 51 | -------------------------------------------------------------------------------- /markdown-to-html/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import Data.Text.Encoding as TEnc 4 | import Data.ByteString as BS 5 | 6 | import CMarkGFM as M 7 | 8 | main = do 9 | t <- TEnc.decodeUtf8 <$> BS.getContents 10 | let out = TEnc.encodeUtf8 $ M.commonmarkToHtml [] [] t 11 | BS.putStr out 12 | -------------------------------------------------------------------------------- /markdown-to-html/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /markdown-to-html/markdown-to-html.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >=1.10 2 | -- Initial package description 'markdown-to-html.cabal' generated by 'cabal 3 | -- init'. For further documentation, see 4 | -- http://haskell.org/cabal/users-guide/ 5 | 6 | name: markdown-to-html 7 | version: 0.1.0.0 8 | -- synopsis: 9 | -- description: 10 | -- bug-reports: 11 | -- license: 12 | license-file: LICENSE 13 | author: Profpatsch 14 | maintainer: mail@profpatsch.de 15 | -- copyright: 16 | -- category: 17 | build-type: Simple 18 | extra-source-files: CHANGELOG.md 19 | 20 | executable markdown-to-html 21 | main-is: Main.hs 22 | -- other-modules: 23 | -- other-extensions: 24 | build-depends: base >=4.12 && <4.13 25 | , cmark-gfm == 0.2.* 26 | , text 27 | -- hs-source-dirs: 28 | default-language: Haskell2010 29 | -------------------------------------------------------------------------------- /notes/blog-requirements.org: -------------------------------------------------------------------------------- 1 | * RSS-feed 2 | ** One item per post 3 | ** One feed per tag 4 | ** Optional: One item per post update 5 | How should that be done? Two ideas: 6 | 1) filter out the git commits that change posts 7 | - might be problematic because minor updates 8 | 2) create updates to articles manually, save them in some format 9 | - maybe diffs? 10 | - maybe another git repo? 11 | ** For link collections one item per update 12 | ** Content template for RSS updates 13 | 14 | * Posts in (Extended)Markdown 15 | ** It should be possible to extend that for interactive stuff 16 | * Notes directly from org-mode files 17 | e.g. for the berkeley sockets 18 | 19 | * Semantic, human readable refs to articles, but also unique IDs 20 | * Interactivity via including Purescript elements 21 | * Automatic publishing 22 | ** Lives in 23 | 24 | 25 | * Tech 26 | 27 | Probably hakyll, since that is Haskell, includes pandoc (markdown) and can do RSS 28 | -------------------------------------------------------------------------------- /notes/dhall-cheatsheet.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Cheatsheet of the dhall configuration language 3 | date: 2019-03-29 4 | author: Profpatsch 5 | --- 6 | 7 | This document describes dhall as of version `6.0.0` of the language 8 | standard (dhall-haskell `0.21`). 9 | 10 | Pipe file to `dhall` to typecheck/evaluate. 11 | `dhall --explain` for extensive error explanations. 12 | 13 | # Syntax 14 | 15 | * `value : type` 16 | * here we use `,` to separate multiple values, which is not valid dhall 17 | * `-- this is a dhall comment` 18 | * `{- this is a multiline comment -}` 19 | * let-syntax 20 | 21 | ``` 22 | let 23 | a = … 24 | let 25 | b = … 26 | in … 27 | ``` 28 | 29 | (also for function aliases and import names) 30 | 31 | ## Scalars 32 | 33 | ``` 34 | True, False : Bool 35 | 0, 1, 2, 3 : Natural 36 | -2, -1, +0, +1, +2 : Integer 37 | -2.0, 3.13158 : Double 38 | "hello world" : Text 39 | ``` 40 | 41 | * TODO: builtin scalar operations 42 | 43 | ### Text 44 | 45 | 1. normal double-quoted strings, Haskell style escaping (`"\"abc\"\ndef"`) 46 | 2. nix-style interpolated, multi-line strings 47 | * newline stripping 48 | 49 | ``` 50 | '' 51 | foo 52 | bar 53 | '' 54 | ``` 55 | 56 | is `"\nfoo\nbar\n"` 57 | 58 | * no newlines & escaping `''` 59 | 60 | ``` 61 | ''foo 62 | '''x 63 | bar'' 64 | ``` 65 | 66 | is `"foo\n''x\nbar"` 67 | 68 | * interpolation 69 | 70 | ``` 71 | let template = 72 | \(name : Text) -> 73 | \(age : Natural) -> 74 | ''${name} is ${Natural/show age} years old'' 75 | in template "bilbo" 24 76 | ``` 77 | 78 | outputs `"bilbo is 24 years old"` 79 | 80 | 81 | ## Complex Types 82 | 83 | ### List 84 | 85 | `[1,2,3] : List Natural` 86 | 87 | * empty lists must be annotated `[] : List Natural` 88 | * items have the same type `[1, "Text"]` (otherwise use Unions) 89 | * `#` concatenates lists: `[ 1 2 3 ] # [ 4 5 ]` => `[ 1 2 3 4 5 ]` 90 | 91 | ### Optional 92 | 93 | * `Some "element" : Optional Text` 94 | * `None Text : Optional Text` 95 | 96 | * an optional element 97 | * `None` takes a type, it is `∀(t: Type) -> Optional t` 98 | * easy to confuse: `None : Natural`, but `None Natural` (application) 99 | 100 | ### Record 101 | 102 | ``` 103 | { foo = True 104 | , bar = 2 } 105 | : { foo : Bool 106 | , bar : Integer } 107 | ``` 108 | 109 | * empty record: `{=} : {}` 110 | * access with `.`: `{ a = False }.a == False` 111 | * record merges 112 | * `//`: right-leaning value record merge: 113 | `{ foo = 4, baz = 7 } // { foo = 5, bar = 6 }` 114 | => `{ foo = 5, bar = 6, baz = 7 }` 115 | * `/\`: recursive value record merge, error on field collision 116 | `{ foo = { a = {=}, b = 2 } } /\ { bar = 3, foo = { c = 4 } }` 117 | => `{ foo = { a = {=}, b = 2, c = 4 }, bar = 3 }` 118 | * `//\\`: *type* record merge, analogous to `/\` 119 | `{ a : Text, b : Integer } //\\ { c : { d : Natural } }` 120 | => `{ a : Text, b : Integer, c : { d : Natural } }` 121 | * record projection 122 | * `{ a = 1, b = 2, c = 3 }.{ a, b }` 123 | => `{ a = 1, b = 2 }` 124 | 125 | ### Union 126 | 127 | TODO: empty fields for 7.0.0 128 | 129 | ``` 130 | let MyUnion = < A : Text | B : Natural | Foo : Text > 131 | let b = MyUnion.B 42 132 | let _ = MyUnion.Foo "hello" 133 | let handlers = 134 | { A = \(_ : Text) -> False 135 | , B = \(n : Natural) -> Natural/even n 136 | , Foo = \(_ : Text) -> True && False } 137 | in 138 | (merge handlers b : Bool) 139 | == True 140 | ``` 141 | 142 | * tagged unions 143 | * merge 144 | * builtin that matches on the tag 145 | * needs to produce the same type for each tag 146 | * always requires an annotation of the output type 147 | 148 | # Computing 149 | 150 | ## Functions 151 | 152 | ``` 153 | let f = \(firstArgument : Text) -> 154 | \(secondArgument : Integer) -> 155 | "some text ${firstArgument} and int ${Integer/show secondArgument}" 156 | in f "my text" +5 157 | ``` 158 | 159 | * types of input arguments are required (not inferred) 160 | 161 | ## Guarantees of Dhall Evaluation 162 | 163 | * non-turing-complete: all evaluations of well-typed dhall code terminate (eventually) 164 | * total: nothing well-typed will ever crash or throw exceptions 165 | * everything will be evaluated as much as possible 166 | * `\(x : t) -> +10 * +10` becomes `\(x : t) -> +100` 167 | 168 | ## Polymorphism 169 | 170 | ``` 171 | let 172 | const = \(t1 : Type) -> 173 | \(x : t1) -> 174 | \(t2 : Type) -> 175 | \(_ : t2) -> 176 | x 177 | in let 178 | id = \(t : Type) -> 179 | \(x : t) -> 180 | x 181 | in 182 | const Bool False Text "text" 183 | == id Bool False 184 | ``` 185 | 186 | * specification of type variables happens explicitely as arguments 187 | 188 | ## Imports 189 | 190 | * Imports: Paths are substituted by their contents 191 | * `./func True 103` 192 | * ` { foo = "abc", bar = 1 } : https://url/to/type` even 193 | 194 | TODO: alternative (fallback) imports with `?`, env imports, `as Text` 195 | imports, `as JSON`? imports, quoted paths, headers, import integrity 196 | hashes, freezing, 197 | 198 | # Misc 199 | 200 | * Alternative Unicode-Syntax for Functions: `λ(x : t) → …` 201 | * Prelude at https://prelude.dhall-lang.org 202 | -------------------------------------------------------------------------------- /notes/execline/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, dhall-prelude, markdown-to-html, runCommandLocal }: 2 | 3 | let 4 | lib = pkgs.lib; 5 | 6 | dhallToNix = { name, projectDir, imports, file }: 7 | let drv = runCommandLocal name {} '' 8 | cp -r ${projectDir}/* . 9 | mkdir ./imports 10 | # TODO: lint for existing imports 11 | ${lib.concatStrings 12 | (lib.mapAttrsToList 13 | (name: dir: "cp -r ${dir} ./imports/${name}\n") 14 | imports 15 | )} 16 | ${pkgs.dhall-nix}/bin/dhall-to-nix < "${file}" > $out 17 | ''; 18 | in 19 | import "${drv}"; 20 | 21 | oneFile = name: file: runCommandLocal name {} '' 22 | mkdir $out 23 | cp ${file} $out/${name} 24 | ''; 25 | 26 | execline-vs-bash = dhallToNix { 27 | name = "foo"; 28 | projectDir = oneFile "execline-vs-bash.dhall" ./execline-vs-bash.dhall; 29 | file = "execline-vs-bash.dhall"; 30 | imports = { 31 | Prelude = dhall-prelude; 32 | }; 33 | } markdown-to-html; 34 | 35 | 36 | in lib.concatMapStringsSep "\n" (v: v { Html = lib.id; Markdown = markdown-to-html; }) execline-vs-bash 37 | -------------------------------------------------------------------------------- /notes/execline/execline-vs-bash.dhall: -------------------------------------------------------------------------------- 1 | -- TODO: loops, parameter handling, heredocs, string-munging 2 | λ(markdownToHtml : Text → Text) 3 | → let Prelude = 4 | ./imports/Prelude/package.dhall 5 | 6 | let el = 7 | λ(bash : Text) 8 | → λ(execline : Text) 9 | → { bash = bash, execline = execline, note = None Text } 10 | 11 | let BashVsDhall = { bash : Text, execline : Text, note : Optional Text } 12 | 13 | let Final = < Markdown : Text | Html : Text > 14 | 15 | let list 16 | : List BashVsDhall 17 | = [ el 18 | "a; b" 19 | "foreground { a } b" 20 | , el "if a; then b; fi" "if { a } b" 21 | , el "if a; then b; fi; c" "foreground { if { a } b } c" 22 | , el "a && b" "if { a } b" 23 | , el "a || b" "ifelse { a } { } b" 24 | ⫽ { note = Some "`{}` is wrong, `{ }` is right" } 25 | , el 26 | "a && b || c" 27 | "ifelse { a } { b } c" 28 | ⫽ { note = 29 | Some 30 | "This is `if`/`then`/`else`; `ifthenelse` is for continuing after the branches finish" 31 | } 32 | , el "if a; then b; else c; fi" "ifelse { a } { b } c" 33 | , el "a && b || c; d" "ifthenelse { a } { b } { c } d" 34 | , el "if a; then b; else c; fi; d" "ifthenelse { a } { b } { c } d" 35 | , el "a &; b" "background { a } b" 36 | , el "a | b | c" "pipeline { a } pipeline { b } c" 37 | , el "a > f" "redirfd -w 1 f a" 38 | , el "a >> f" "redirfd -a 1 f a" 39 | , el "a < f" "redirfd -r 0 f a" 40 | ⫽ { note = 41 | Some "redirfd is very powerful, see help page for more info" 42 | } 43 | , el "a >&2" "fdmove -c 1 2 a" 44 | ⫽ { note = Some "`fdmove 1 2` without `-c` closes 2" } 45 | ] 46 | 47 | let optText = 48 | λ(opt : Optional Text) 49 | → Optional/fold Text opt Text (λ(t : Text) → t) "" 50 | 51 | let toFinal 52 | : List BashVsDhall → List Final 53 | = λ(list : List BashVsDhall) 54 | → let element = 55 | λ(x : BashVsDhall) 56 | → Final.Html 57 | '' 58 | 59 |
${x.bash}
60 |
${x.execline}
61 | ${markdownToHtml (optText x.note)} 62 | 63 | '' 64 | 65 | in [ Final.Markdown "ehlo dis is template\n" 66 | , Final.Html 67 | '' 68 | 69 | 70 | 71 | 72 | 73 | 74 | '' 75 | ] 76 | # Prelude.List.map BashVsDhall Final element list 77 | # [ Final.Html "
bashexeclinenote
\n" ] 78 | 79 | in toFinal list 80 | -------------------------------------------------------------------------------- /notes/literate-devops-with-emacs.org: -------------------------------------------------------------------------------- 1 | [[https://www.youtube.com/watch?v=dljNabciEGg&feature=youtu.be][link to the video]] \\ 2 | [[http://howardism.org/Technical/Emacs/literate-devops.html][original essay]] 3 | 4 | * General 5 | - Write in past tense so you don’t have to re-edit when mailing 6 | 7 | * Running Code 8 | 9 | [[http://orgmode.org/org.html#Working-with-source-code][relevant org-mode docs]] 10 | 11 | - cource code blocks can be created with ~~ 12 | - =C-c C-c= executes 13 | - you first have to add the languages you want to be able to execute to 14 | =org-babel-load-languages= 15 | - ~:exports [code|results|both|none]~ to export code/ 16 | - ~:dir ~ relative path for cwd 17 | - =C-c '= to open code block in its own buffer 18 | - ~:tangle ~ to export code block to file 19 | - code block attributes can be put in a section property, like 20 | #+BEGIN_SRC org 21 | :PROPERTIES: 22 | :dir: 23 | :END: 24 | #+END_SRC 25 | - name blocks with ~#+NAME: ~ (shortcut: ==) 26 | 27 | * Code Block Variables 28 | 29 | ~#+BEGIN_SRC :var VARNAME=~ 30 | 31 | Note that =something= can be the name of a code block, then the value will be 32 | the output of that code block. 33 | 34 | - ~:results table~ returns a table that can be indexed like ~table[2,3]~ 35 | 36 | * Executing Remote Code 37 | 38 | You can use tramp filenames and it will execute remotely 39 | 40 | ~:dir: /scp:my.server.com:mydir~ 41 | 42 | * Transforming outputs with another source code block 43 | 44 | Create another code block that uses a variable, call this function from the 45 | first block with the ~:post~ command: 46 | 47 | #+BEGIN_SRC org 48 | \#+BEGIN_SRC :results value list :post column1(data=*this*) 49 | bla 50 | \#+END_SRC 51 | 52 | \#+BEGIN_SRC elisp :var data="" :results value 53 | (mapcar 'car data) 54 | \#+END_SRC 55 | #+END_SRC 56 | 57 | Source code blocks that can be used in multiple projects can be put into the 58 | org-mode “tower of babel”. (Personal note: It is debatable whether this is a 59 | good idea, since now everything depends on your local setup.) 60 | 61 | * Misc tramp Goodies 62 | ** Speeding up tramp connections with sessions 63 | Add a ~:session: