Inventory/schemas: move all schemas to legacyPackages
This commit is contained in:
@@ -128,7 +128,7 @@ It is possible to add services to multiple machines via tags as shown
|
|||||||
Or it can build anytime via:
|
Or it can build anytime via:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nix build git+https://git.clan.lol/clan/clan-core#inventory-schema
|
nix build git+https://git.clan.lol/clan/clan-core#schemas.inventory
|
||||||
> result
|
> result
|
||||||
> ├── schema.cue
|
> ├── schema.cue
|
||||||
> └── schema.json
|
> └── schema.json
|
||||||
|
|||||||
@@ -25,20 +25,6 @@ in
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
packages.inventory-schema-abstract = pkgs.stdenv.mkDerivation {
|
|
||||||
name = "inventory-schema";
|
|
||||||
buildInputs = [ pkgs.cue ];
|
|
||||||
src = ./.;
|
|
||||||
buildPhase = ''
|
|
||||||
export SCHEMA=${builtins.toFile "inventory-schema.json" (builtins.toJSON self'.legacyPackages.schemas.inventory)}
|
|
||||||
cp $SCHEMA schema.json
|
|
||||||
cue import -f -p compose -l '#Root:' schema.json
|
|
||||||
mkdir $out
|
|
||||||
cp schema.cue $out
|
|
||||||
cp schema.json $out
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
legacyPackages.schemas = (
|
legacyPackages.schemas = (
|
||||||
import ./schemas {
|
import ./schemas {
|
||||||
inherit
|
inherit
|
||||||
|
|||||||
@@ -30,10 +30,31 @@ let
|
|||||||
"E501"
|
"E501"
|
||||||
];
|
];
|
||||||
} ./render_schema.py;
|
} ./render_schema.py;
|
||||||
|
|
||||||
|
inventory-schema-abstract = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "inventory-schema-files";
|
||||||
|
buildInputs = [ pkgs.cue ];
|
||||||
|
src = ./.;
|
||||||
|
buildPhase = ''
|
||||||
|
export SCHEMA=${builtins.toFile "inventory-schema.json" (builtins.toJSON inventorySchema)}
|
||||||
|
cp $SCHEMA schema.json
|
||||||
|
# Also generate a CUE schema version that is derived from the JSON schema
|
||||||
|
cue import -f -p compose -l '#Root:' schema.json
|
||||||
|
mkdir $out
|
||||||
|
cp schema.cue $out
|
||||||
|
cp schema.json $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit inventorySchema modulesSchema renderSchema;
|
inherit
|
||||||
|
inventorySchema
|
||||||
|
modulesSchema
|
||||||
|
renderSchema
|
||||||
|
inventory-schema-abstract
|
||||||
|
;
|
||||||
|
|
||||||
|
# Inventory schema, with the modules schema added per role
|
||||||
inventory =
|
inventory =
|
||||||
pkgs.runCommand "rendered"
|
pkgs.runCommand "rendered"
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
jsonSchema=$(nix build .#inventory-schema-abstract --print-out-paths)/schema.json
|
jsonSchema=$(nix build .#schemas.inventory-schema-abstract --print-out-paths)/schema.json
|
||||||
nix run .#classgen "$jsonSchema" "$PKG_ROOT/clan_cli/inventory/classes.py"
|
nix run .#classgen "$jsonSchema" "$PKG_ROOT/clan_cli/inventory/classes.py"
|
||||||
@@ -47,7 +47,8 @@
|
|||||||
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-abstract classgen;
|
inherit (self'.packages) classgen;
|
||||||
|
inherit (self'.legacyPackages.schemas) inventory-schema-abstract;
|
||||||
clan-core-path = clanCoreWithVendoredDeps;
|
clan-core-path = clanCoreWithVendoredDeps;
|
||||||
includedRuntimeDeps = [
|
includedRuntimeDeps = [
|
||||||
"age"
|
"age"
|
||||||
@@ -56,7 +57,8 @@
|
|||||||
};
|
};
|
||||||
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-abstract classgen;
|
inherit (self'.packages) classgen;
|
||||||
|
inherit (self'.legacyPackages.schemas) inventory-schema-abstract;
|
||||||
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;
|
||||||
};
|
};
|
||||||
@@ -71,7 +73,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema-abstract}/schema.json ./clan_cli/inventory/classes.py --stop-at "Service"
|
${self'.packages.classgen}/bin/classgen ${self'.legacyPackages.schemas.inventory-schema-abstract}/schema.json ./clan_cli/inventory/classes.py --stop-at "Service"
|
||||||
|
|
||||||
python docs.py reference
|
python docs.py reference
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
@@ -89,7 +91,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema-abstract}/schema.json ./clan_cli/inventory/classes.py --stop-at "Service"
|
${self'.packages.classgen}/bin/classgen ${self'.legacyPackages.schemas.inventory-schema-abstract}/schema.json ./clan_cli/inventory/classes.py --stop-at "Service"
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
# Retrieve python API Typescript types
|
# Retrieve python API Typescript types
|
||||||
python api.py > $out/API.json
|
python api.py > $out/API.json
|
||||||
@@ -113,7 +115,7 @@
|
|||||||
classFile = "classes.py";
|
classFile = "classes.py";
|
||||||
};
|
};
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${self'.packages.classgen}/bin/classgen ${self'.packages.inventory-schema-abstract}/schema.json b_classes.py --stop-at "Service"
|
${self'.packages.classgen}/bin/classgen ${self'.legacyPackages.schemas.inventory-schema-abstract}/schema.json b_classes.py --stop-at "Service"
|
||||||
file1=$classFile
|
file1=$classFile
|
||||||
file2=b_classes.py
|
file2=b_classes.py
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,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-abstract}/schema.json $PKG_ROOT/clan_cli/inventory/classes.py --stop-at "Service"
|
${self'.packages.classgen}/bin/classgen ${self'.legacyPackages.schemas.inventory-schema-abstract}/schema.json $PKG_ROOT/clan_cli/inventory/classes.py --stop-at "Service"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user