Revert "Fix: forward meta attributes in flake-parts module"

This reverts commit e7c6333e06.

The propagated `self` attribute can be an error in non `flake-parts`
modules.
This commit is contained in:
a-kenji
2024-08-07 12:34:03 +02:00
committed by kenji
parent 40ea12610c
commit 10f7509a5f
4 changed files with 29 additions and 26 deletions

View File

@@ -11,7 +11,6 @@
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
@@ -28,9 +27,14 @@ let
; ;
self = directory; self = directory;
}; };
rest = builtins.removeAttrs attrs [ "specialArgs" ]; meta = attrs.meta or { };
rest = builtins.removeAttrs attrs [
"meta"
"specialArgs"
];
in in
eval { eval {
inventory.meta = lib.mapAttrs (_: lib.mkDefault) meta;
imports = [ imports = [
rest rest
# implementation # implementation

View File

@@ -1,4 +1,4 @@
{ lib, self, ... }: { lib, ... }:
let let
types = lib.types; types = lib.types;
in in
@@ -7,7 +7,6 @@ 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";
}; };
@@ -27,18 +26,22 @@ in
}; };
# Meta # Meta
meta = lib.mkOption { meta = {
type = types.nullOr ( name = lib.mkOption {
types.submodule { type = types.nullOr types.str;
options = { default = null;
name = lib.mkOption { description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.";
type = types.nullOr types.str; };
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";
); };
default = null; description = lib.mkOption {
type = types.nullOr types.str;
default = null;
description = "A short description of the clan";
};
}; };
pkgsForSystem = lib.mkOption { pkgsForSystem = lib.mkOption {

View File

@@ -201,8 +201,6 @@ 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;

View File

@@ -15,13 +15,10 @@ in
{ {
test_only_required = test_only_required =
let let
config = evalClan { config = evalClan { directory = ./.; };
meta.name = "test";
imports = [ ./module.nix ];
};
in in
{ {
expr = config.inventory ? meta; expr = config.pkgsForSystem null == null;
expected = true; expected = true;
}; };
@@ -96,9 +93,10 @@ in
in in
{ {
expr = result.clanInternals.meta; expr = result.clanInternals.meta;
expectedError = { expected = {
type = "ThrownError"; description = "description";
msg = ""; icon = "icon";
name = "superclan";
}; };
}; };