Merge pull request 'fix: forward meta attributes in flake-parts module' (#1852) from kenji/clan-core:forward-meta into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/1852
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
directory, # The directory containing the machines subdirectory # allows to include machine-specific modules i.e. machines.${name} = { ... }
|
directory, # The directory containing the machines subdirectory # allows to include machine-specific modules i.e. machines.${name} = { ... }
|
||||||
# A map from arch to pkgs, if specified this nixpkgs will be only imported once for each system.
|
# A map from arch to pkgs, if specified this nixpkgs will be only imported once for each system.
|
||||||
# This improves performance, but all nipxkgs.* options will be ignored.
|
# This improves performance, but all nipxkgs.* options will be ignored.
|
||||||
|
# deadnix: skip
|
||||||
inventory ? { },
|
inventory ? { },
|
||||||
## Sepcial inputs (not passed to the module system as config)
|
## Sepcial inputs (not passed to the module system as config)
|
||||||
specialArgs ? { }, # Extra arguments to pass to nixosSystem i.e. useful to make self available # A set containing clan meta: name :: string, icon :: string, description :: string
|
specialArgs ? { }, # Extra arguments to pass to nixosSystem i.e. useful to make self available # A set containing clan meta: name :: string, icon :: string, description :: string
|
||||||
@@ -27,14 +28,9 @@ let
|
|||||||
;
|
;
|
||||||
self = directory;
|
self = directory;
|
||||||
};
|
};
|
||||||
meta = attrs.meta or { };
|
rest = builtins.removeAttrs attrs [ "specialArgs" ];
|
||||||
rest = builtins.removeAttrs attrs [
|
|
||||||
"meta"
|
|
||||||
"specialArgs"
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
eval {
|
eval {
|
||||||
inventory.meta = lib.mapAttrs (_: lib.mkDefault) meta;
|
|
||||||
imports = [
|
imports = [
|
||||||
rest
|
rest
|
||||||
# implementation
|
# implementation
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ lib, ... }:
|
{ lib, self, ... }:
|
||||||
let
|
let
|
||||||
types = lib.types;
|
types = lib.types;
|
||||||
in
|
in
|
||||||
@@ -7,6 +7,7 @@ in
|
|||||||
# Required options
|
# Required options
|
||||||
directory = lib.mkOption {
|
directory = lib.mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
|
default = self;
|
||||||
description = "The directory containing the clan subdirectory";
|
description = "The directory containing the clan subdirectory";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -26,22 +27,18 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Meta
|
# Meta
|
||||||
meta = {
|
meta = lib.mkOption {
|
||||||
|
type = types.nullOr (
|
||||||
|
types.submodule {
|
||||||
|
options = {
|
||||||
name = lib.mkOption {
|
name = lib.mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
default = null;
|
|
||||||
description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.";
|
description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.";
|
||||||
};
|
};
|
||||||
icon = lib.mkOption {
|
|
||||||
type = types.nullOr types.path;
|
|
||||||
default = null;
|
|
||||||
description = "A path to an icon to be used for the clan in the GUI";
|
|
||||||
};
|
};
|
||||||
description = lib.mkOption {
|
}
|
||||||
type = types.nullOr types.str;
|
);
|
||||||
default = null;
|
default = null;
|
||||||
description = "A short description of the clan";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pkgsForSystem = lib.mkOption {
|
pkgsForSystem = lib.mkOption {
|
||||||
|
|||||||
@@ -201,6 +201,8 @@ in
|
|||||||
imports = [
|
imports = [
|
||||||
# Merge the inventory file
|
# Merge the inventory file
|
||||||
{ inventory = inventoryLoaded; }
|
{ inventory = inventoryLoaded; }
|
||||||
|
# Merge the meta attributes from the buildClan function
|
||||||
|
{ inventory.meta = if config.meta != null then config.meta else { }; }
|
||||||
];
|
];
|
||||||
|
|
||||||
inherit nixosConfigurations;
|
inherit nixosConfigurations;
|
||||||
|
|||||||
@@ -15,10 +15,13 @@ in
|
|||||||
{
|
{
|
||||||
test_only_required =
|
test_only_required =
|
||||||
let
|
let
|
||||||
config = evalClan { directory = ./.; };
|
config = evalClan {
|
||||||
|
meta.name = "test";
|
||||||
|
imports = [ ./module.nix ];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
expr = config.pkgsForSystem null == null;
|
expr = config.inventory ? meta;
|
||||||
expected = true;
|
expected = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,10 +96,9 @@ in
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
expr = result.clanInternals.meta;
|
expr = result.clanInternals.meta;
|
||||||
expected = {
|
expectedError = {
|
||||||
description = "description";
|
type = "ThrownError";
|
||||||
icon = "icon";
|
msg = "";
|
||||||
name = "superclan";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user