Skip to content

Commit 3ba936c

Browse files
authored
Merge pull request #559 from MattSturgeon/config-wrappers
feat: add `withConfig` & `buildConfig` from nixpkgs
2 parents ce65379 + b0731a2 commit 3ba936c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

nix/packages/treefmt/default.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,19 @@ in
7474

7575
passthru = let
7676
inherit (perSystem.self) treefmt;
77+
78+
# Inherits an attr from pkgs.treefmt, overriding the `treefmt` arg if possible
79+
inheritFromNixpkgs = name: let
80+
error = "Accessing `${name}` requires a nixpkgs revision that has `treefmt.${name}`.";
81+
attr = pkgs.treefmt.${name} or (throw error);
82+
in
83+
if attr.override.__functionArgs.treefmt or null != null
84+
then attr.override {inherit treefmt;}
85+
else attr;
7786
in {
87+
withConfig = inheritFromNixpkgs "withConfig";
88+
buildConfig = inheritFromNixpkgs "buildConfig";
89+
7890
no-vendor-hash = treefmt.overrideAttrs {
7991
vendorHash = "";
8092
};

0 commit comments

Comments
 (0)