Recently got started with Nix and Home-Manager. I thought Advent Of Code would be a good way to get more comfortable with the Nix language.

I don’t think I ever made it beyond Day 6 though, even in my most comfortable language (Python) so no idea where this will strand.

I am learning a lot about Nix though!

Have you used the Nix language outside of configuration? Let’s share and discuss!

You are viewing a single thread.
View all comments View context
1 point

@gavin @F04118F yup! thats a link to a 2019 AoC, but here’s my video for day 1 this year https://www.youtube.com/live/P_3rUzAN0vw?si=W0qxiwKeDHVN_2aQ
the code is here: https://github.com/ellyxir/advent_of_code/tree/main/2024/nix/day01

i looked at your solution, good work!

permalink
report
parent
reply
2 points

That looks very lispy, is that intentional?

permalink
report
parent
reply
1 point

Yes, Nix is a pure functional programming language, like Lisp.

The reason for its existence is to allow for reproducible and repeatable builds of packages and configuration. This is the basis for nixpkgs, NixOS and Home Manager.

permalink
report
parent
reply
2 points
*

Oh, I know; I have commit access to Nixpkgs ;)

I was just commenting on the way they’ve styled their Nix code here.

permalink
report
parent
reply
1 point
*

Your code looks awesome, I’m definitely going to steal some ideas from that, especially the lib.pipe really cleans up a lot of unnecessary bindings I did.

Doing a with import ./utils.nix is also a lot cleaner than nesting let statements.

permalink
report
parent
reply
1 point

@F04118F which I promptly did away with because I couldn’t be arsed today lol

permalink
report
parent
reply
1 point

Nix regex sucks. Is there any package with a reasonable regex matchAll?

permalink
report
parent
reply
3 points
*

You can also use the pipe operators; but they are still experimental features.

foo (bar (baz x)) = x |> baz |> bar |> foo = foo <| bar <| baz <| x

permalink
report
parent
reply