mirror of
https://github.com/srid/haskell-flake.git
synced 2024-08-15 17:00:41 +03:00
settings: add removeReferencesTo
(#225)
This setting helps remove unnecessary dependencies to your haskell package that
bloats up the final closure size
Source: 5623bb3814/nix/removeReferencesTo.nix (L9)
---------
Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
This commit is contained in:
parent
88715ebf33
commit
5113f700d6
@ -3,6 +3,7 @@
|
||||
## Unreleased
|
||||
|
||||
- #210: Add `extraLibraries` to `settings` module.
|
||||
- #225: settings: add `removeReferencesTo`
|
||||
- #215: Improved debug logging.
|
||||
- #216: Remove `debug` option (pass `--trace-verbose` to nix instead)
|
||||
- Fixes
|
||||
|
@ -46,7 +46,18 @@ haskellProjects.default = {
|
||||
|
||||
## Custom settings {#custom}
|
||||
|
||||
- [Emanote overrides](https://github.com/srid/emanote/commit/5b24bd04f94e03afe66ee01da723e4a05d854953): demonstrates how to add a *new* setting option (`removeReferencesTo`).
|
||||
You can provide custom settings for use in multiple packages (even across multiple repos). For example, see [this Emanote change](https://github.com/srid/emanote/commit/5b24bd04f94e03afe66ee01da723e4a05d854953) which demonstrates how to add a *new* setting option (`removeReferencesTo`).
|
||||
|
||||
## Extra settings {#extra}
|
||||
|
||||
haskell-flake provides the following settings on top of those provided by [nixpkgs].
|
||||
|
||||
### `removeReferencesTo`
|
||||
|
||||
Remove references to other packages from this Haskell package. This is useful to eliminate unnecessary data dependencies from your Haskell executable so as to reduce its closure size.
|
||||
|
||||
> [!info] For more, see
|
||||
> - https://github.com/NixOS/nixpkgs/pull/204675
|
||||
> - https://srid.ca/remove-references-to
|
||||
|
||||
[nixpkgs]: https://nixos.asia/en/nixpkgs
|
@ -311,6 +311,28 @@ in
|
||||
impl = triggerRebuild;
|
||||
};
|
||||
|
||||
removeReferencesTo = {
|
||||
type = types.listOf types.package;
|
||||
description = ''
|
||||
Packages to remove references to.
|
||||
|
||||
This is useful to ditch unnecessary data dependencies from your Haskell
|
||||
executable so as to reduce its closure size.
|
||||
|
||||
cf.
|
||||
- https://github.com/NixOS/nixpkgs/pull/204675
|
||||
- https://srid.ca/remove-references-to
|
||||
'';
|
||||
impl = disallowedReferences: drv:
|
||||
drv.overrideAttrs (old: rec {
|
||||
inherit disallowedReferences;
|
||||
postInstall = (old.postInstall or "") + ''
|
||||
${lib.concatStrings (map (e: "echo Removing reference to: ${e}\n") disallowedReferences)}
|
||||
${lib.concatStrings (map (e: "remove-references-to -t ${e} $out/bin/*\n") disallowedReferences)}
|
||||
'';
|
||||
});
|
||||
};
|
||||
|
||||
# When none of the above settings is suitable:
|
||||
custom = {
|
||||
type = types.functionTo types.package;
|
||||
|
Loading…
Reference in New Issue
Block a user