DEV Community

loading...
Cover image for 97th day of code meditations:: an ocean of NixOS

97th day of code meditations:: an ocean of NixOS

dooygoy profile image Domagoj Miskovic ・6 min read

... I am in the 97th day, still at the beginning of 100 days of code journey, the days and nights go slow, searching for a clear mirror like realization of sum types, Haskell moon is illuminating the lake of my mind, and the weather is wet outside, and so the dark moon approaches, just few more days, now it smiles then it goes black, I go up into my inner me, into my mind's eye, where there is just statelessness, just a functional vibe, a flowing current, so I'm thinking NixOS operating system, a type of a Linux distribution with a declarative functional configuration management style. And the baby is just crying, again, he cries each day, each morning, each evening, though there seem to be moments off, a certain restfulness when we feel at ease, with almost nothing to do. I am in my second month of parenting, how should I put it, it is intense. Are these side effects? Are my interactions monadic operations comes to my mind often, as if Haskell could encapsulate it somehow? Am I being productive?

Mouthful-y described as a purely functional distribution, constructed out of some type of atoms, traceable identifiers, hashtags, it calls out into the wilderness of an untyped universe, ready to adapt like a borg vessel in transwarp space, it can even consume any linux distributions within itself, spreading like a virus, it lustrates through the system and installs itself deleting the previous distribution. It seems easier to interlink the functional code, to make new pathways into new domains,

..we show that it is possible to manage systems in a radically different way by moving to a purely functional model. In this model, the static artifacts of a running system – software packages, configuration files, system startup scripts, etc. – are generated by functions in a purely functional specification language. Just like values in a purely functional language, these artifacts never change after they have been built; rather, the system is updated to a new configuration by changing the specification and rebuilding the system from that specification. This allows a system to be built deterministically, and therefore reproducibly. It allows the user to roll back the system to previous configurations,since these are not overwritten. Perhaps most importantly, statelessness makes configuration actions predictable: they do not mysteriously fail because of some unknown aspect of the state of the system.

Freedom of movement within the system, a declaration of independence, independent and unique, statelessness, the stress of the matter, the method of having less state and more lessness, uniquely different, the most average, common, a free system, open, I'm just brainstorming myself and now I stop.

Sum types and product types are still enumerating themselves in my mind, because they seem so basic and simple and yet profoundly deep. Instantiated by an inner eye, the mind at work, I rest in wonder of the possible ways one can mentally construct and realize, visually follow the process of computation, how it is situated, a body of relationships, pure relations, form a mental data structure, aware of the space time complexity structure of the data, the action itself, like refurbishing a conceptual after image, like an illuminated field within a static shell frozen in time, Data or Picard call it a static warp shell, the structure itself, its body defined by a function, a function whose body contains various variants, a function like a part of a fractal construction constructed for itself from self similar functions, functions as first class citizens...

So anyway, I was just about to upload an image of a mandala and Upload Image on dev.to says in red: "Image has an unsupported type"

That's too bad. This looks like an error, an exception. In the mean time I check the twitter sphere and others are reporting their 100daysofcode experiences on my timeline, they work on a tangible project, a program, a real life application while I am still thinking about the logic of these function applications.

Alt Text

Backus advocated high-level combining forms such as map and reduce(fold), rather than low-level constructions such as sequencing or iterating statements, which is echoed in the “point-free” programming style popular in Haskell today.

Alt Text

So these context containers, these first class citizens, these vessels of meanings in action seem to realize themselves in the form of data structures, like data Bool whose definition of bool :: a -> a -> Bool -> a shows how a bool has a type, has a type is implied with the mysterious four dots, ::, depicting has a type somewhere in the four directions of the world, well nothing that extravagant, just a double colon meaning has a type. What does this type do? Well, a type Bool is some type which generates a boolean value such as True and/or False, meaning it produces a value of type Bool, this value being shown as an unknown variable name a, a character a, so when we compare two boolean values we get a boolean value back, false or true. What does this boolean mean in particular? Merely a pathway from True to True, from one station to another, or from True to False, to something else, still continuing, but something else, the other side of it, the b of the a b. What is True for you? Notice the if then else programming statement, as some sort of boolean pathway, try if True then True else False. What is different here is a form of a conditional imperative statement, something what describes an operational flow of data, a certain state in time and space, but is it impure? to ask in a side effect chaos, who knows what can be passed to an if then else statement, who knows what computes as False or True?

So here I edit the draft of my yesterdays thoughts on NixOS, which happened in the afternoon hours, when the I am quite burned out happy after the morning spent in Haskell forest, now being just guilty of being in awe, totally in awe of NixOS, described as an declarative operating system with a, should we call it, a declarative semantic space, meaning the user is being more involved with the work itself, being engaged with the system at a higher level, writing functional code away from the act of changing the state, the user can mentally observe a text file, a configuration.nix file, seen through a textual editor, vim or emacs, within the /etc/system/ path.

Alt Text

OK, so we are within the innumerable ocean of nix expressions, and we feel good about the translucent quality of untyped functional expressions. Why untyped? Are there any side effects here? Is there a prejudice , a bias? Let us just take a step back and interact with out operating systems, be it Mac, Win or Linux/GNU/BSD varieties. One of the most basic operations a user does, besides logging into the computer, signing into the session, into the desktop environment, a desktop window, a virtual space where our interactions take place, is installing new programs, and this is only possible when such an operation is allowed, when the user has super right to change the state of the system. At least that is what most people are familiar with, getting some functionality inside the computer, worse case, even installing that newer version word processor they have at work.

What sets NixOS apart from the entire existence of operating systems, is that you declare what you want to install and the operating system, NixOS does it for you. You ask for things and NixOS brings them to you. Comparing that experience with distributions like Archlinux, its minimalism, happening in real time, typing out the imperative commands, issuing commands, we are essentially changing state in the system as the state evolves, how to go back, to a previous known state, sudo apt install program or sudo dnf install ... or sudo pacman -S.

The NixOS configuration file /etc/nixos/configuration.nix is actually a Nix expression, which is the Nix package manager’s purely functional language for describing how to build packages and configurations. This means you have all the expressive power of that language at your disposal, including the ability to abstract over common patterns, which is very useful when managing complex systems.

I am entering my fourth day of my 97th day. I think I will stop and begin the 96th day. I need a refresher, I am looking forward watching and typing along a youtube video "Nixpkgs - Adding a package to unstable/master branch"

Discussion (0)

pic
Editor guide