Conversation

Jarkko Sakkinen

Edited 1 month ago
Nix:

1. Claims to be a functional language.
2. Still complains about declaration order.

I purposely put declarations in alphabetical order in my kernel testing shenanigans because I thought that it would stand the test.

What disappointment ;-)

#nix #nixos
2
0
1
... please don't take this dead seriously ;-)
0
0
0

@jarkko Declaration order does not matter (e.g. order of bindings in a let expression or attrset (object)), but functional languages can express both declarative and non-declarative solutions.
Strikingly a function has a before (argument) and an after (return value).
It matters a lot how it's used. lib.fix makes the argument and return value the same value.
Declarative systems built with the Nix language tend to use fixpoints created with such helpers, including evalModules aka the Module System.

1
0
1
@roberth, thanks for informative response appreciate it!

I did this during last week timeline in self-discovery mode without actually knowing what I'm doing but eventually got things working:

https://gitlab.com/jarkkojs/linux-tpmdd-nixos/-/blob/main/flake.nix?ref_type=heads

The project aims to do firmware and OS images for testing my master at kernel.org. Here the particular statements that I were referring to with that post are kernel* statements in the let expression. If I put them in alphabetical order the build system will complain.

I do faintly recall from algebra classes preimages and image and fixed point combinators so what you're saying is not totally alien to me but neither do I fully connect that to this reality nor how "lib.fix" connects to the basic algebra concept :-)

I did this project because I got idea that maybe I could use the combination of Nix and Docker (Podman) to replace my old Buildroot environment. Together they kind of create a rudimentary embedded build system...
2
1
1

Jarkko Sakkinen

Edited 1 month ago
@roberth self-discovery mode, i.e. i peeked and poked without much sleep or not knowing what i'm doing for about a week until i started to get output that i was looking for :-) that's how the current flake.nix and configuration.nix materialized...
1
0
0

@jarkko Got it. You've configured an undeclarative thing with a functional/declarative tool. We do that a lot with Nix.

The fixed points thing is interesting if you're into theory or digging into libraries, but it's perfectly fine to know that there's a connection, and just use the existing tooling without deep thoughts about the related math. Basically it lets us name one or two abstract things, but a lot of fixed point usage in math isn't all that relevant to what we do with it.

1
0
0

@jarkko yeah, nixosSystem is evalModules underneath. Flake.nix also has recursive let bindings, the way it's evaluated internally by Nix. Not factored out to have a fix call, but broadly the same kind of recursion. outputs is called with its return value plus extras in the self argument.

0
0
1
@roberth I'm always interested on internals so I thank you for all the wisdom :-) This highlighted me that there exist a thing called "lib.fix" so over time I can dive deeper and have some fuzzy ideas at least. And at least I know the abstract concept of fixed point combinators from algebra classes...

I'm just sort of "build useful product first, learn second" rather than other way around :-) I did something and now I want to learn what I actually did.
1
0
1
@roberth I also think as per learning using Nix like without installing it as a building block for embedded image builder together with Docker/Podman has thought me probably more right from the get go than if I had repealed and replaced my Fedora installation with NixOS :-) I really had to "get" some of the bits to make this right and ended up even do a bit of programming (at least the version parser).

You can enjoy operating systems in many ways :-)
0
0
0