Skip to content

Instantly share code, notes, and snippets.

@lukego
Created February 1, 2017 14:50
Show Gist options
  • Save lukego/692bedff26e17a5a892bbc53cc2e4758 to your computer and use it in GitHub Desktop.
Save lukego/692bedff26e17a5a892bbc53cc2e4758 to your computer and use it in GitHub Desktop.
# Create R visualizations of Snabb timeline logs
with import <nixpkgs> {};
with stdenv; with lib;
let
snabb = (import ../snabb).timeline-pmu;
timelineCSV = shm:
mkDerivation {
name = "timeline-csv";
src = shm;
buildInputs = [ snabb ];
sourceRoot = ".";
prePath = "set -eux";
buildPhase = ''
/var/setuid-wrappers/sudo ${./timeline2csv.sh} shm timeline.csv
'';
installPhase = ''
mkdir -p $out
cp timeline.csv $out/
'';
};
in
{
timeline = timelineCSV /home/luke/shm/var/run/snabb/29771;
}
#!/usr/bin/env bash
if [ $# != 2 ]; then
echo "Usage: $0 <shmdir> <output>"
exit 1
fi
timeline=$1/engine/timeline
csv=$2
[ -f $timeline ] || (echo "file not found: $timeline"; exit 1)
snabb snsh -e "require('core.timeline').dump('$timeline')" > $csv
@lukego
Copy link
Author

lukego commented Feb 1, 2017

Output:

[luke@interlaken:~/git/studio/nix/timeline]$ nix-build
these derivations will be built:
  /nix/store/caqs3p8y48a0mm8ajba0xn0hk94hws21-timeline-csv.drv
building path(s) ‘/nix/store/8l2yzh0c6a206pdly5qcai7z1xyycm83-timeline-csv’
unpacking sources
unpacking source archive /nix/store/9r4qmsj68bbc4s7m0s8qcrgxmr0j9in8-29771
source root is .
setting SOURCE_DATE_EPOCH to timestamp 1485960641 of file ./env-vars
warning: file ./env-vars may be generated; SOURCE_DATE_EPOCH may be non-deterministic
patching sources
configuring
grep: : No such file or directory
grep: : No such file or directory
no configure script, doing nothing
building
sudo: unable to execute /nix/store/nn6fdxncm06cv3dh3knanwb7gxj3w9s4-timeline2csv.sh: No such file or directory
installing
cp: cannot stat 'timeline.csv': No such file or directory
builder for ‘/nix/store/caqs3p8y48a0mm8ajba0xn0hk94hws21-timeline-csv.drv’ failed with exit code 1
error: build of ‘/nix/store/caqs3p8y48a0mm8ajba0xn0hk94hws21-timeline-csv.drv’ failed

@lukego
Copy link
Author

lukego commented Feb 1, 2017

After s/prePath/prePatch/:

[luke@interlaken:~/git/studio/nix/timeline]$ nix-build
these derivations will be built:
  /nix/store/q0f076y9kpjk76xbgnvxd8dw5whz5flp-timeline-csv.drv
building path(s) ‘/nix/store/dpsrls97wk6hg0bhwlphzf53ays99q1d-timeline-csv’
unpacking sources
unpacking source archive /nix/store/9r4qmsj68bbc4s7m0s8qcrgxmr0j9in8-29771
source root is .
setting SOURCE_DATE_EPOCH to timestamp 1485960732 of file ./env-vars
warning: file ./env-vars may be generated; SOURCE_DATE_EPOCH may be non-deterministic
patching sources
++ return 0
/nix/store/62h3c4d6rdnlxichixqg8h9jxi8nhxk0-stdenv/setup: line 612: patches: unbound variable
+++ exitHandler
+++ exitCode=1
+++ set +e
+++ closeNest
+++ '[' 1 -gt 0 ']'
+++ stopNest
+++ nestingLevel=0
+++ echo -en '\033[q'
+++ '[' 0 -gt 0 ']'
/nix/store/62h3c4d6rdnlxichixqg8h9jxi8nhxk0-stdenv/setup: line 124: showBuildStats: unbound variable
builder for ‘/nix/store/q0f076y9kpjk76xbgnvxd8dw5whz5flp-timeline-csv.drv’ failed with exit code 1
error: build of ‘/nix/store/q0f076y9kpjk76xbgnvxd8dw5whz5flp-timeline-csv.drv’ failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment