Your one-stop-cake-shop for everything Freshly Baked has to offer

feat(ingredients): infer more ingredient names

We would like to infer the hostname and username as ingredients if they
exist. This will let us remove even more ingredients that we obviously
want included. Some homes don't have the system name specified, or don't
have ingredients by that name, for those we want to avoid erroring

+37 -23
-6
packetmix/homes/default.nix
··· 22 22 "espanso" 23 23 "freshlybakedcake" 24 24 "gaming" 25 - "maya" 26 25 "niri" 27 26 "nix-index" 28 27 "remote" ··· 45 44 "espanso" 46 45 "freshlybakedcake" 47 46 "gaming" 48 - "minion" 49 47 "niri" 50 48 "nix-index" 51 49 "remote" ··· 69 67 "espanso" 70 68 "freshlybakedcake" 71 69 "gaming" 72 - "minion" 73 70 "niri" 74 71 "nix-index" 75 - "redhead" 76 72 "remote" 77 73 "scriptfs" 78 74 ]; ··· 89 85 ]; 90 86 ingredients = [ 91 87 "catppuccin" 92 - "coded" 93 88 "development" 94 89 "espanso" 95 90 "freshlybakedcake" ··· 117 112 "freshlybakedcake" 118 113 "gaming" 119 114 "nix-index" 120 - "pinea" 121 115 "remote" 122 116 "scriptfs" 123 117 ];
+28 -5
packetmix/lib/ingredients.nix
··· 156 156 [ ] 157 157 ); 158 158 159 + # Gets the names of all ingredients, based on just a directory 160 + # 161 + # this: {ingredientsDirectory -> moduleName[]} 162 + # 163 + # ingredientsDirectory: {path} the path in which your ingredients reside 164 + # moduleName[]: {string[]} names of all ingredients in your ingredientsDirectory 165 + getIngredientsNames = 166 + ingredientsDirectory: 167 + let 168 + ingredientsDirectoryListing = builtins.readDir ingredientsDirectory; 169 + ingredientSubdirectories = nilla.lib.attrs.filter ( 170 + _: value: value == "directory" 171 + ) ingredientsDirectoryListing; 172 + ingredientNames = builtins.attrNames ingredientSubdirectories; 173 + in 174 + ingredientNames; 175 + 159 176 # Gets modules for all ingredients, based on just a directory and any argument overrides 160 177 # Includes all required option declarations (under options.ingredient.${name}.enable for each ingredient) and conditional auto-imports 161 178 # Includes any options, imports, etc. that are defined in *any* ingredient, even if it is not enabled ··· 170 187 collectIngredientsModules = 171 188 ingredientsDirectory: overrideArgs: 172 189 let 173 - ingredientsDirectoryListing = builtins.readDir ingredientsDirectory; 174 - ingredientSubdirectories = nilla.lib.attrs.filter ( 175 - _: value: value == "directory" 176 - ) ingredientsDirectoryListing; 177 - ingredientNames = builtins.attrNames ingredientSubdirectories; 190 + ingredientNames = this.getIngredientsNames ingredientsDirectory; 178 191 modules = map (this.collectIngredientModules ingredientsDirectory overrideArgs) ingredientNames; 179 192 in 180 193 nilla.lib.lists.flatten modules; 194 + 195 + # Gets whether an ingredient exists, based on a directory name and a 196 + # 197 + # this: {ingredientsDirectory -> name -> exists} 198 + # 199 + # ingredientsDirectory: {path} the path in which your ingredients reside 200 + # name: {string} the name of the ingredient to search for 201 + # exists: {boolean} whether that ingredient exists 202 + ingredientExists = 203 + ingredientsDirectory: name: builtins.elem name (this.getIngredientsNames ingredientsDirectory); 181 204 }; 182 205 }
+3 -2
packetmix/modules/ingredients.nix
··· 7 7 options.systems.nixos = 8 8 let 9 9 ingredientModules = nilla.config.lib.ingredients.collectIngredientsModules ../systems { }; 10 + ingredientExists = nilla.config.lib.ingredients.ingredientExists ../systems; 10 11 in 11 12 nilla.lib.options.create { 12 13 type = nilla.lib.types.attrs.of ( ··· 14 15 { config, name, ... }@submodule: 15 16 { 16 17 options.ingredients = nilla.lib.options.create { 17 - description = "Ingredients to activate for the system. Defaults to the common ingredient"; 18 + description = "Ingredients to activate for the system. Defaults to the common ingredient, as well as the ingredient named as the system's hostname if it exists"; 18 19 type = nilla.lib.types.list.of nilla.lib.types.string; 19 20 }; 20 21 21 22 config = { 22 - ingredients = [ "common" ]; 23 + ingredients = [ "common" ] ++ (if ingredientExists name then [ name ] else [ ]); 23 24 modules = 24 25 ingredientModules 25 26 ++ (map (ingredient: {
+6 -2
packetmix/modules/nilla-home/homes-type.nix
··· 42 42 ); 43 43 44 44 username = builtins.elemAt home_name_parts 0; 45 + hostname = builtins.elemAt home_name_parts 2; 45 46 system = builtins.elemAt home_name_parts 4; 46 47 48 + hostnameProvided = hostname != null; 47 49 systemProvided = system != null; 48 50 49 51 defaultModules = [ ··· 96 98 }; 97 99 98 100 ingredients = nilla.lib.options.create { 99 - description = "Ingredients to activate for the home. Defaults to the common ingredient"; 101 + description = "Ingredients to activate for the home. Defaults to the common ingredient, as well as one or more of the ingredients named as the username and the hostname if they are set in the home name and the ingredients exist"; 100 102 type = nilla.lib.types.list.of nilla.lib.types.string; 101 103 }; 102 104 ··· 111 113 config = { 112 114 ingredients = [ 113 115 "common" 114 - ]; 116 + ] 117 + ++ (if ingredientExists username then [ username ] else [ ]) 118 + ++ (if hostnameProvided && ingredientExists hostname then [ hostname ] else [ ]); 115 119 modules = 116 120 defaultModules 117 121 ++ ingredientModules
-8
packetmix/systems/default.nix
··· 18 18 "niri" 19 19 "personal" 20 20 "portable" 21 - "redhead" 22 21 ]; 23 22 args = { 24 23 system = "x86_64-linux"; ··· 29 28 config.systems.nixos."emden" = { 30 29 pkgs = nixpkgs.x86_64-linux; 31 30 ingredients = [ 32 - "emden" 33 31 "espanso" 34 32 "freshlybakedcake" 35 33 "gaming" ··· 50 48 "espanso" 51 49 "freshlybakedcake" 52 50 "javelin" 53 - "marbled" 54 51 "minion" 55 52 "niri" 56 53 "personal" ··· 70 67 "freshlybakedcake" 71 68 "gaming" 72 69 "niri" 73 - "ocicat" 74 70 "personal" 75 71 "portable" 76 72 ]; ··· 89 85 "kde" 90 86 "personal" 91 87 "pinea" 92 - "saurosuchus" 93 88 ]; 94 89 args = { 95 90 system = "x86_64-linux"; ··· 107 102 "gaming" 108 103 "niri" 109 104 "personal" 110 - "shorthair" 111 105 ]; 112 106 args = { 113 107 system = "x86_64-linux"; ··· 119 113 pkgs = nixpkgs.x86_64-linux; 120 114 ingredients = [ 121 115 "freshlybakedcake" 122 - "midnight" 123 116 "server" 124 117 ]; 125 118 args = { ··· 131 124 pkgs = nixpkgs.x86_64-linux; 132 125 ingredients = [ 133 126 "freshlybakedcake" 134 - "teal" 135 127 "server" 136 128 ]; 137 129 args = {