Skip to content

Commit

Permalink
feat: Autodetect extensions from composer.json.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Feb 4, 2022
1 parent fb29d5f commit 19ea3a0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
config = { allowUnfree = true; };
};

# Get composer file into set
composer = builtins.fromJSON (builtins.readFile "${builtins.getEnv "PWD"}/composer.json");
# Get "require" section
require = (if (composer ? require) then composer.require else {});
# Copy the keys of a set in a value
exts = nixpkgs.lib.attrsets.mapAttrs' (name: value: nixpkgs.lib.nameValuePair name name) require;
# Convert the set into a list
exts2 = (map (key: builtins.getAttr key exts) (builtins.attrNames exts));
# Filter out values not starting with "ext-"
exts3 = builtins.filter (x: (builtins.substring 0 4 x) == "ext-") exts2;
# Get rid of the first 4 characters in the name
userExtensions = map (x: builtins.substring 4 (builtins.stringLength x) x) exts3;

extensionsGroups = {
mandatory = [
"bcmath"
Expand All @@ -30,7 +43,7 @@
"posix"
"intl"
"opcache"
];
] ++ userExtensions;

optional = [
"calendar"
Expand Down

0 comments on commit 19ea3a0

Please sign in to comment.