Stream: cull-os

Topic: Fixing what Nix did wrong


view this post on Zulip RGBCube (Jun 21 2024 at 18:38):

(copied from the matrix; this is about fixing flakes being a new concept and destroying the "everything is a derivation" concept of Nix; also see this post https://jade.fyi/blog/flakes-arent-real)

The way I want to fix this in Cab is overridable expressions.

{ a = 1; } ==> a * a

assuming this is assigned to b, just evaluating b will get you 1. But overriding it like b <== { a = 2; } and then evaluating that expression will get you 4. The trick here is that ==> is not a function symbol (unlike :, which has the same behavior in Cab as in Nix)

So you will be able to do things like

inputs @ {
  packages = import <github:cull-os/packages> <== inputs;
} ==> {
  packages.bar = packages.buildCrate ./.;
}

import will import /${<github:cull-os/cab>}/default.cab, which is another expression like our default.cab. Then it will override it, with our inputs. The trick here is that our inputs were already overriden by the Cab CLI, which did <== { buildSystem = ...; targetSystem = ...; } so the build and target systems get passed into CullOS packages. Then we get a neat attribute set packed with packages configured for our target.

view this post on Zulip RGBCube (Jun 21 2024 at 18:42):

I also want to implement the "standard library" in Pure Rust, eagerly checking for types of things. This will also make it a part of the language instead of some unrelated repository like nixpkgs. And it will be faster, as a result.

view this post on Zulip RGBCube (Jul 13 2024 at 21:10):

cc @Jonathan Ringer

view this post on Zulip RGBCube (Jul 13 2024 at 21:11):

this would work without "overrideable expressions" in Nix too. But it would require you to call everything, which is fine I guess

view this post on Zulip RGBCube (Oct 26 2024 at 19:50):

Don't Do The Mistakes Of Nix

Link: <https://md.darmstadt.ccc.de/nix2>

Notable stuff:

view this post on Zulip Tim DeHerrera (Oct 26 2024 at 21:16):

it might ne nice, although I'm not sure how feasible, if all functions can have default args, not just functions that take a set

view this post on Zulip RGBCube (Oct 27 2024 at 10:18):

Hmm, would be interesting. So you're saying

<pat> ? "default here" will default to "default here" if <pat> fails to match, ensuring the whole pattern always does?

view this post on Zulip RGBCube (Oct 27 2024 at 10:18):

This is actually pretty generic, I like it.

view this post on Zulip RGBCube (Oct 27 2024 at 10:20):

Though, you can't really use this to implement defaulting functions. How would you do first [1, 2, 3] and first 2 [1, 2, 3] with this? (not with type checking of the value, like \nOrXs :: list | number: if type nOrXs == number ...)

view this post on Zulip RGBCube (Oct 27 2024 at 10:22):

\first = \n :: number ? null:
  if n == null then # didn't match, but we can't access the list either... it's totally ignored
    \[x, ...]: x # now the user has to do `first [] [1, 2, 3]
  else
    getFirstN n;

view this post on Zulip RGBCube (Oct 27 2024 at 10:32):

Huh, this actually doesn't make sense at all

view this post on Zulip RGBCube (Oct 27 2024 at 10:32):

(n :: number) ? "foo" what the hell are you even binding "foo" to?

view this post on Zulip RGBCube (Oct 27 2024 at 10:32):

You can't possibly know, unless you invent extremely weird semantics

view this post on Zulip RGBCube (Oct 27 2024 at 10:33):

Even then, what happens when you match this and it fails: [1, ..., 99] ? "bar"

view this post on Zulip RGBCube (Oct 27 2024 at 10:33):

I'll think about this more today, but this concept I thought of doesn't work

view this post on Zulip RGBCube (Oct 27 2024 at 10:38):

Currently Cab lacks these things that are in Nix:

view this post on Zulip RGBCube (Oct 27 2024 at 10:41):

To avoid:

Funky semantics of or defaults

9ecca769-ccd8-4983-ab88-99fea13a2ef3.png

Attribute select is not individual, which is wack. I don't want this behavior, I want the semantic equivalent of (a.b).c or 1.

Strings in attribute-check

Since strings are never used for identifiers in Cab, this isn't an issue. But might as well say this won't be a thing:

myset ? "attra".attrb."attrc"

Last updated: Nov 21 2024 at 09:45 UTC