Open shivaraj-bh opened 4 weeks ago
Upon inheriting stderr
of child process (to display progress of underlying nix command), we can no longer capture it, breaking nix_eval_attr.
Do we need nix_eval_attr
to rely on stderr
to conclude that an attribute is missing? Could we use flake-schemas here?
Making flake-schemas
recognise om
flake output isn’t that hard: https://github.com/shivaraj-bh/flake-schemas/commit/037434d5bad1f4f66598e5925265f2036ca2a1ba
Oh no, It doesn’t:
"om": {
"doc": "Configuration for `omnix` CLI.\n",
"output": {
"children": {
"ci": {
"leaf": true
},
"health": {
"leaf": true
}
}
}
},
I will have to recursively mkChildren
to include the entire configuration in the schema.
Upon recursively creating these children, it seems to sorta work:
"om": {
"doc": "Configuration for `omnix` CLI.\n",
"output": {
"children": {
"ci": {
"children": {
"default": {
"children": {
"cli-test-dep-cache": {
"children": {
"dir": {
"leaf": true
}
}
},
"doc": {
"children": {
"dir": {
"leaf": true
}
}
},
"flakreate-registry": {
"children": {
"dir": {
"leaf": true
}
}
},
"omnix": {
"children": {
"dir": {
"leaf": true
}
}
}
}
}
}
},
But if you notice, along with “leaf” we don’t have the attribute mentioning the “value” of the leaf node, even though it is added in the schema:
{
let
omSchema = {
version = 1;
doc = ''
Configuration for `omnix` CLI.
'';
inventory = output:
let
recurse = prefix: attrs: self.lib.mkChildren (builtins.mapAttrs
(attrName: attrs:
if (builtins.typeOf attrs) != "set" then
{
value = attrs;
what = "omnix config";
}
else
recurse (prefix + attrName + ".") attrs
)
attrs);
in
recurse "" output;
};
in
}
That is an easy fix in nix
, see: https://github.com/shivaraj-bh/nix/commit/1d23c1e871981f5666a12c4409bd0574fc1e1e02
Note to self: Mention this use case in flake-schemas
PR along with examples.
voila
"om": {
"doc": "Configuration for `omnix` CLI.\n",
"output": {
"children": {
"ci": {
"children": {
"default": {
"children": {
"cli-test-dep-cache": {
"children": {
"dir": {
"leaf": true,
"value": "crates/omnix-cli/tests",
"what": "omnix config"
}
}
},
"doc": {
"children": {
"dir": {
"leaf": true,
"value": "doc",
"what": "omnix config"
}
}
},
"flakreate-registry": {
"children": {
"dir": {
"leaf": true,
"value": "crates/flakreate/registry",
"what": "omnix config"
}
}
},
"omnix": {
"children": {
"dir": {
"leaf": true,
"value": ".",
"what": "omnix config"
}
}
}
}
}
}
},
See also #211 (omnix flake-module)
We also want to support the scenario of there not being any om
configuration in the flake (so as to default back to the Default::default
value).
Is flake-schemas really relevant here? Consider the maintenance burden we would be taking on. Keeping all 3 places -- Rust types, flake-parts module, and flake-schema -- in sync.
Is flake-schemas really relevant here? Consider the maintenance burden we would be taking on. Keeping all 3 places -- Rust types, flake-parts module, and flake-schema -- in sync.
Rust types
https://github.com/juspay/omnix/issues/214 should solve the burden of maintaining Rust types?
flake-parts module
Aren’t we maintaining the flake-parts module in omnix
itself?
flake-schema
That would require maintaining a fork until the upstream merge happens, I can keep this up-to-date, now that I am slowly getting familiarised with the nix
codebase.
I did try to find different ways to not rely on the stderr
output, but unless there is a way to print flake output as json, I don’t see anything better than using flake-schemas
.
Feel free to explore the flake-schemas route. I'd be curious to see how it looks, in the end. Right now, I don't have a clear of idea of what is entailed.
That would require maintaining a fork until the upstream merge happens, I can keep this up-to-date, now that I am slowly getting familiarised with the nix codebase.
Can't the flake-schema live in this repo itself? I thought flake-schemas are meant to be decentralized, anyway (i.e., downstream flakes can specify their own schemas).
Rust types
214 should solve the burden of maintaining Rust types?
For om show
, yes.
Not necessarily for stuff like #216
Here's an idea: keep Rust types as canonical source of truth, and then generate the Nix expression necessary for creating flake-parts module and flake-schema from it ... in the same vein as https://hackage.haskell.org/package/purescript-bridge
This PR changes a bunch of things, to make the review simpler here are the primary changes:
nix eval
, making nix_eval_attr
, nix_eval_qualified_attr
and omnix-common::OmConfig::from_flake_url
redundant, should we still support them along with supporting missing_attribute
check via nix eval
?Leaf
enum has been removed for simplicity while defining custom serializer for FlakeOutputs
(Had to merge from main
because I just wanted to try running it on some flakes..)
Functionally, it works quite well:
@srid added a couple of TODO’s to the description, feel free to add more if I missed any
Update the usage example in show.md
@srid do you mean to update the example itself? i.e to show something with less of “N/A” or to show the progress of “nix flake show” due to inherited stderr?
Former. Less of N/A.
Update the usage example in show.md
Nevermind; I thought we are doing om show
on this repo itself, but this is happening on nixos-config
.
Anyway, I pushed some nix changes to master. Refactors, moving of clippy drv to checks, removing nix_health package, and adding doc/clippy for omnix-common. om show
on this repo now displays:
I don’t see the description for the apps in the screenshot
That was run from main
branch.
description to apps in main branch was added in https://github.com/juspay/omnix/pull/251?
Huh, ignore my last screenshot. I think I ran it using om from my nixos-config. Here's the latest:
(This was run from the omnix-init
branch, but that one is up to date with main
).
Apart from Refactoring flake-schemas/flake.nix
, this PR is almost ready. @srid should we bother keeping eval.rs
, now that it isn’t being used anywhere?
We can get rid of eval.rs
. By the way, I don't understand the Filtered output types much. But I'll take a look a bit later.
(You can also drop by huddle to pair on it)
resolves #209
We also use
flake-schemas
in this PR to fetch theom
config from the flake output instead of usingnix eval
(since inheritingstderr
means it's no longer captured forom
to process). An additional, unintended benefit of usingflake-schemas
is caching the output ofnix flake show
.Changes in nix CLI
https://github.com/shivaraj-bh/nix/commit/1d23c1e871981f5666a12c4409bd0574fc1e1e02
Demo
TODO
nix_rs
changeloghistory.md
flake-schemas
as local flake (foromSchema
) while importing majority of schemas from DetSys/flake-schemasfind_qualified_attr_in_flake_output
toFlakeOutputs
FlakeOutputs
serialization… use untagged for flatteningnix/flake-schemas/flake.nix