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!

        • F04118F@feddit.nlOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          15 days ago

          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.

          • Atemu@lemmy.ml
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            10 days ago

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

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

      • F04118F@feddit.nlOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        17 days ago

        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.

        • kintrix@linux.community
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          17 days ago

          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

              • F04118F@feddit.nlOP
                link
                fedilink
                English
                arrow-up
                1
                ·
                15 days ago

                Somehow I completely missed that split can do match groups… Oopsie! I did it in Python today but I did make a completely functional (and way too complicated) algorithm.

                Tap for spoiler

                The way you handle the do and dont is much cleaner

                .

                • Ellyse@ohai.social
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  15 days ago

                  @F04118F if i had known about match i probably would have gotten stuck also lol but luckily i used split once before and remembered it :) i made an issue in your github, hope thats ok, just to mention this in case you didnt see it on fedi!

                  • F04118F@feddit.nlOP
                    link
                    fedilink
                    English
                    arrow-up
                    1
                    ·
                    15 days ago

                    Yeah I was planning on changing the salty README and referencing your comment, thanks for putting the reminder there!