Merge pull request 'CLI: Improve Inventory schema usage' (#2115) from hsjobeki/clan-core:hsjobeki-main into main
This commit is contained in:
@@ -84,6 +84,19 @@ in
|
|||||||
cp schema.json $out
|
cp schema.json $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
packages.inventory-schema-abstract = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "inventory-schema";
|
||||||
|
buildInputs = [ pkgs.cue ];
|
||||||
|
src = ./.;
|
||||||
|
buildPhase = ''
|
||||||
|
export SCHEMA=${builtins.toFile "inventory-schema.json" (builtins.toJSON bareSchema.abstractSchema)}
|
||||||
|
cp $SCHEMA schema.json
|
||||||
|
cue import -f -p compose -l '#Root:' schema.json
|
||||||
|
mkdir $out
|
||||||
|
cp schema.cue $out
|
||||||
|
cp schema.json $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
packages.inventory-schema-pretty = pkgs.stdenv.mkDerivation {
|
packages.inventory-schema-pretty = pkgs.stdenv.mkDerivation {
|
||||||
name = "inventory-schema-pretty";
|
name = "inventory-schema-pretty";
|
||||||
buildInputs = [ pkgs.cue ];
|
buildInputs = [ pkgs.cue ];
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
nixpkgs,
|
nixpkgs,
|
||||||
includedRuntimeDeps,
|
includedRuntimeDeps,
|
||||||
|
|
||||||
inventory-schema,
|
inventory-schema-abstract,
|
||||||
classgen,
|
classgen,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -63,7 +63,7 @@ let
|
|||||||
ln -sf ${nixpkgs'} $out/clan_cli/nixpkgs
|
ln -sf ${nixpkgs'} $out/clan_cli/nixpkgs
|
||||||
cp -r ${../../templates} $out/clan_cli/templates
|
cp -r ${../../templates} $out/clan_cli/templates
|
||||||
|
|
||||||
${classgen}/bin/classgen ${inventory-schema}/schema.json $out/clan_cli/inventory/classes.py --stop-at "Service"
|
${classgen}/bin/classgen ${inventory-schema-abstract}/schema.json $out/clan_cli/inventory/classes.py --stop-at "Service"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Create a custom nixpkgs for use within the project
|
# Create a custom nixpkgs for use within the project
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
packages = {
|
packages = {
|
||||||
clan-cli = pkgs.python3.pkgs.callPackage ./default.nix {
|
clan-cli = pkgs.python3.pkgs.callPackage ./default.nix {
|
||||||
inherit (inputs) nixpkgs;
|
inherit (inputs) nixpkgs;
|
||||||
inherit (self'.packages) inventory-schema classgen;
|
inherit (self'.packages) inventory-schema-abstract classgen;
|
||||||
clan-core-path = clanCoreWithVendoredDeps;
|
clan-core-path = clanCoreWithVendoredDeps;
|
||||||
includedRuntimeDeps = [
|
includedRuntimeDeps = [
|
||||||
"age"
|
"age"
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
};
|
};
|
||||||
clan-cli-full = pkgs.python3.pkgs.callPackage ./default.nix {
|
clan-cli-full = pkgs.python3.pkgs.callPackage ./default.nix {
|
||||||
inherit (inputs) nixpkgs;
|
inherit (inputs) nixpkgs;
|
||||||
inherit (self'.packages) inventory-schema classgen;
|
inherit (self'.packages) inventory-schema-abstract classgen;
|
||||||
clan-core-path = clanCoreWithVendoredDeps;
|
clan-core-path = clanCoreWithVendoredDeps;
|
||||||
includedRuntimeDeps = lib.importJSON ./clan_cli/nix/allowed-programs.json;
|
includedRuntimeDeps = lib.importJSON ./clan_cli/nix/allowed-programs.json;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,6 @@ mkShell {
|
|||||||
|
|
||||||
# Generate classes.py from inventory schema
|
# Generate classes.py from inventory schema
|
||||||
# This file is in .gitignore
|
# This file is in .gitignore
|
||||||
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema}/schema.json $PKG_ROOT/clan_cli/inventory/classes.py --stop-at "Service"
|
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema-abstract}/schema.json $PKG_ROOT/clan_cli/inventory/classes.py --stop-at "Service"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user