Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created October 12, 2019 03:24
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cleverca22/be6d6bd78230f5e624d2b626d5b677a5 to your computer and use it in GitHub Desktop.
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "nix-fork";
src = ./.;
buildInputs = [ nix boost ];
}
#include <nix/value.hh>
using namespace nix;
extern "C" void nixFork(EvalState &state, Value &v) {
v.type = tInt;
v.integer = 42;
}
fork.so: fork.cpp
g++ $< -o $@ -shared
test1: fork.so
nix-instantiate --eval test-incremental.nix --allow-unsafe-native-code-during-evaluation
.PHONY: test1
builtins.importNative ./fork.so "nixFork"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment