Love nix? Now you can use it as a programming language also!
Create file:
# add.nix
input: input + input
Run it like this:
$ nixla add.nix Hello
HelloHello
Or like this:
$ echo Hello | nixla add.nix
HelloHello
# mul_all_numbers.nix
let
inherit (builtins) filter split foldl' fromJSON;
split_ = sep_regex: str:
filter
(el: el != [])
(split sep_regex str);
in
input:
foldl'
(acc: el: acc * el)
1
(map
fromJSON # works as toInt
(split_ " " input)
)
Run it:
$ nixla-nix mul_all_numbers.nix 2 3 7
42
Or using pipes:
$ echo 2 3 7 | nixla-nix mul_all_numbers.nix
42
# mylib.nix
{
add = input: input + input;
}
# import-mylib.nix
let
inherit (import ./mylib.nix) add;
in
input:
add input
Run it:
$ nixla import-mylib.nix Hello
HelloHello
- github:dmyTRUEk/btree-nixla - some binary tree operations (such as parsing from text, printing indented, reversing, traversing)
- github:dmyTRUEk/aoc2024 - Advent of Code 2024 solutions