From e979a6ea728caa4870f3ae009351b7df2d9a5593 Mon Sep 17 00:00:00 2001 From: niksingh710 Date: Mon, 10 Feb 2025 20:38:56 +0530 Subject: [PATCH 1/5] feat(schema): Added schema for process-compose. [debug-based] * Fully depended on debug flag of flake-parts. --- nix/flake-schemas/flake.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nix/flake-schemas/flake.nix b/nix/flake-schemas/flake.nix index 988ef455..20555cbb 100644 --- a/nix/flake-schemas/flake.nix +++ b/nix/flake-schemas/flake.nix @@ -79,6 +79,30 @@ }) output); }; + processComposeSchema = { + version = 1; + doc = '' + The `apps` output provides commands available via `nix run`. + ''; + inventory = output: + flake-schemas.lib.mkChildren (builtins.listToAttrs (map + (system: { + name = system; + value = flake-schemas.lib.mkChildren (builtins.mapAttrs + (processes: definition: + { + evalChecks.isValidProcess = + definition ? settings && + definition ? package; + derivation = definition.package; + what = "Process Compose"; + evalOnAllSystems = true; + }) + (output.${system}.process-compose or { })); + }) + [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ])); + }; + in { schemas = flake-schemas.schemas // { @@ -87,6 +111,7 @@ nixosConfigurations = nixosConfigurationsSchema; homeConfigurations = homeConfigurationsSchema; darwinConfigurations = darwinConfigurationsSchema; + allSystems = processComposeSchema; }; }; } From 91367450bbf299999caa3ffd81f65a7ebb31b99f Mon Sep 17 00:00:00 2001 From: niksingh710 Date: Mon, 10 Feb 2025 20:39:32 +0530 Subject: [PATCH 2/5] output: Added allSystems Tabular output --- crates/omnix-cli/src/command/show.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/omnix-cli/src/command/show.rs b/crates/omnix-cli/src/command/show.rs index 8fa30ef0..c8e326d4 100644 --- a/crates/omnix-cli/src/command/show.rs +++ b/crates/omnix-cli/src/command/show.rs @@ -146,6 +146,14 @@ impl ShowCommand { self.flake_url )), ); + print_flake_output_table( + "🔄 Process Compose", + &["allSystems", system.as_ref()], + Some(format!( + "nix run {}#", + self.flake_url + )), + ); print_flake_output_table("🔧 NixOS Modules", &["nixosModules"], None); print_flake_output_table( "🐳 Docker Images", From 3fc27ec7bc4172b94a72434905ea163b7834361e Mon Sep 17 00:00:00 2001 From: niksingh710 Date: Mon, 10 Feb 2025 21:53:14 +0530 Subject: [PATCH 3/5] check: isValidProcess will consider settings key only. --- nix/flake-schemas/flake.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nix/flake-schemas/flake.nix b/nix/flake-schemas/flake.nix index 20555cbb..87dd1ccc 100644 --- a/nix/flake-schemas/flake.nix +++ b/nix/flake-schemas/flake.nix @@ -92,9 +92,7 @@ (processes: definition: { evalChecks.isValidProcess = - definition ? settings && - definition ? package; - derivation = definition.package; + definition ? settings; what = "Process Compose"; evalOnAllSystems = true; }) From 1c2e3cd4d0feacb40f2c275c9ef44ca631258fb7 Mon Sep 17 00:00:00 2001 From: niksingh710 Date: Mon, 10 Feb 2025 21:55:03 +0530 Subject: [PATCH 4/5] comments: Added comments for debug flag --- nix/flake-schemas/flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/flake-schemas/flake.nix b/nix/flake-schemas/flake.nix index 87dd1ccc..62a4ece8 100644 --- a/nix/flake-schemas/flake.nix +++ b/nix/flake-schemas/flake.nix @@ -80,6 +80,10 @@ output); }; processComposeSchema = { + # Enabling flake-parts `debug` flag is required for this schema to work. + # https://flake.parts/options/flake-parts.html#opt-debug + # TODO: https://github.com/Platonic-Systems/process-compose-flake should provide schema for it self + # So that omnix at runtime can fetch and merge the schema from the flake version = 1; doc = '' The `apps` output provides commands available via `nix run`. From 6db9752cc4b962cb26b75cf453ca0a7dc219b32f Mon Sep 17 00:00:00 2001 From: niksingh710 Date: Wed, 12 Feb 2025 02:01:56 +0530 Subject: [PATCH 5/5] added(systems): added nix-system/default as systems flake This will handle Arm MacBooks too --- nix/flake-schemas/flake.lock | 18 +++++++++++++++++- nix/flake-schemas/flake.nix | 5 +++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/nix/flake-schemas/flake.lock b/nix/flake-schemas/flake.lock index 2e259ccb..f19b0461 100644 --- a/nix/flake-schemas/flake.lock +++ b/nix/flake-schemas/flake.lock @@ -17,7 +17,23 @@ }, "root": { "inputs": { - "flake-schemas": "flake-schemas" + "flake-schemas": "flake-schemas", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/nix/flake-schemas/flake.nix b/nix/flake-schemas/flake.nix index 62a4ece8..fd63445a 100644 --- a/nix/flake-schemas/flake.nix +++ b/nix/flake-schemas/flake.nix @@ -1,8 +1,9 @@ { inputs = { flake-schemas.url = "github:DeterminateSystems/flake-schemas"; + systems.url = "github:nix-systems/default"; }; - outputs = { flake-schemas, ... }: + outputs = inputs@{ flake-schemas, ... }: let appsSchema = { version = 1; @@ -102,7 +103,7 @@ }) (output.${system}.process-compose or { })); }) - [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ])); + (import inputs.systems))); }; in