(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.
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.
cc @Jonathan Ringer
this would work without "overrideable expressions" in Nix too. But it would require you to call everything, which is fine I guess
Link: <https://md.darmstadt.ccc.de/nix2>
Notable stuff:
?
for attribute bind defaults and attribute existence checking at the same time. Very unsure about the syntax for both of these things..4
float syntax. Make 0x.3
invalid, too.\n
no matter what. People can do string.replace "\n" "\r\n"
if they desire.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
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?
This is actually pretty generic, I like it.
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 ...
)
\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;
Huh, this actually doesn't make sense at all
(n :: number) ? "foo"
what the hell are you even binding "foo" to?
You can't possibly know, unless you invent extremely weird semantics
Even then, what happens when you match this and it fails: [1, ..., 99] ? "bar"
I'll think about this more today, but this concept I thought of doesn't work
Currently Cab lacks these things that are in Nix:
car ? headlight.lightbulb
{ n ? 0 }: n ** n
car.headlight.lightbulb or "nope"
To avoid:
or
defaults9ecca769-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
.
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