Nix-writers

From NixOS Wiki
Revision as of 22:08, 21 April 2019 by imported>Lassulus (Add nix-writers skeleton)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Nix-writers are a way to write other programming languages inline in nix-code. Basically it's like writeScript/writeScriptBin but for other Languages.

Every writer has a ...Bin variant which can be used inside environment.systemPackages. Most of the writers take an attrributeset where one can add libraries.

Languages

bash

This is basically writeScript but with the shebang to bash already included.

pkgs.writers.writeBash "hello_world" ''
  echo 'hello world!'
''

C

pkgs.writers.writeC "hello-world-ncurses" { libraries = [ pkgs.ncurses ]; } ''
  #include <ncurses.h>
  int main() {
    initscr();
    printw("Hello World !!!");
    refresh(); endwin();
    return 0;
  }
''

dash

pkgs.writers.writeDash "hello_world" ''
  echo 'hello world!'
''


Haskell

JavaScript

Perl

Python2

Python3