Skip to content

Instantly share code, notes, and snippets.

@thoughtpolice
Created August 3, 2018 14:43
Show Gist options
  • Save thoughtpolice/ac5ecc46a922b4b886e03b9548f194bb to your computer and use it in GitHub Desktop.
Save thoughtpolice/ac5ecc46a922b4b886e03b9548f194bb to your computer and use it in GitHub Desktop.
with import <nixpkgs> {};
let
source = lib.writeFile "something.cc" ''
#include <stdio.h>
int main(void) { printf("%d\n", 42); return 0; }
'';
in
stdenv.mkDerivation {
name = "example";
phases = [ "buildPhase" ];
buildPhase = ''
mkdir -p $out/bin
cc -o $out/bin/example ${source}
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment