stagit-generate.nix (2954B)
1 {pkgs, ...}: let 2 css = '' 3 body,pre{font-family:monospace} 4 #blob,article img{max-width:100%} 5 html{font-size:12px;height:100%} 6 body{margin:5rem auto;color:#aaa;background-color:#272727;width:66rem} 7 pre{-moz-tab-size:4;tab-size:4} 8 h1,h2,h3,h4,h5,h6{font-size:1em;margin:0} 9 h1,h2,img{vertical-align:middle} 10 img{border:0} 11 a,a.d,a.h,a.i,a.line{color:#3498db;text-decoration:none} 12 #blob{display:block;overflow-x:scroll} 13 article.markup{font-size:15px;border:2px solid #00000017;border-radius:10px;font-family:sans-serif;padding:2.5em;margin:2em 0} 14 article.markup code{font-size:.9em;border:1px solid #dbdbdb;background-color:#f7f7f7;padding:0 .3em;border-radius:.3em} 15 article.markup pre code{border:none;background:0 0;padding:0;border-radius:0} 16 article.markup pre{background-color:#f7f7f7;padding:1em;border:1px solid #dbdbdb;border-radius:.3em} 17 article.markup h1{font-size:2.4em;padding-bottom:6px;border-bottom:5px solid #0000000a} 18 article.markup h2{font-size:1.9em;padding-bottom:5px;border-bottom:2px solid #00000014} 19 article.markup h3{font-size:1.5em} 20 article.markup h4{font-size:1.3em} 21 article.markup h5{font-size:1.1em} 22 article.markup h6{font-size:1em} 23 .linenos{margin-right:0;border-right:1px solid;user-select:none} 24 .linenos a{margin-right:.9em;user-select:none;text-decoration:none} 25 #blob a,.desc{color:#777} 26 table thead td{font-weight:700} 27 table td{padding:0 .4em} 28 #content table td{vertical-align:top;white-space:nowrap} 29 #branches tr:hover td,#files tr:hover td,#index tr:hover td,#log tr:hover td,#tags tr:hover td{background-color:#414141} 30 #branches tr td:nth-child(3),#index tr td:nth-child(2),#log tr td:nth-child(2),#tags tr td:nth-child(3){white-space:normal} 31 td.num{text-align:right} 32 hr{border:0;border-top:1px solid #777;height:1px} 33 .A,pre a.i,span.i{color:#29b74e} 34 .D,pre a.d,span.d{color:#e42533} 35 .url td:nth-child(2){padding-top:.2em;padding-bottom:.9em} 36 .url td:nth-child(2) span{padding:1px 5px;background-color:#eee;border:1px solid #ddd;border-radius:5px} 37 .url td:nth-child(2) span a{color:#444} 38 ''; 39 stagit-generate = pkgs.writeShellScriptBin "stagit-generate" '' 40 # variables 41 source_directory="$HOME/vault/src" 42 destination_directory="$HOME/docker/stagit" 43 mkdir -p "$destination_directory" 44 # stagit loop 45 for repo in $(find "$source_directory" -type d -name '.git' | sed 's|/\.git$||'); do 46 output_directory="$destination_directory/$(basename "$repo")" 47 mkdir -p "$output_directory" 48 cd "$output_directory" || exit 49 echo "Generating $(basename "$repo")..." 50 ${pkgs.stagit}/bin/stagit "$repo" 51 cat > "style.css" <<EOF 52 ${css} 53 EOF 54 done 55 # index 56 cd "$destination_directory" || exit 57 ${pkgs.stagit}/bin/stagit-index "''${source_directory}/"*/ >index.html 58 cat > "style.css" <<EOF 59 ${css} 60 EOF 61 ''; 62 in { 63 environment.systemPackages = [stagit-generate]; 64 }