mirror of
https://github.com/srid/haskell-flake.git
synced 2024-10-05 18:47:18 +03:00
Make buildFromSdist
configurable; turn it off by default (#253)
This commit is contained in:
parent
c614e2c44f
commit
3a8c1b58cf
@ -11,6 +11,7 @@
|
||||
- #223 Make `devShell.tools` a `lazyAttrsOf` (lazy evaluation of values)
|
||||
- Breaking changes
|
||||
- #221: Switch to `buildFromSdist`, to allow using non-standard package sets (wherein `cabal-install` is otherwise built without using user's overrides)
|
||||
- #253: Turn off `buildFromSdist` by default. It can now be enabled manually by setting `settings.<name>.buildFromSdist` to `true`.
|
||||
|
||||
## 0.4.0 (Aug 22, 2023)
|
||||
|
||||
|
@ -55,9 +55,14 @@ haskell-flake provides the following settings on top of those provided by [nixpk
|
||||
### `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
|
||||
|
||||
### `buildFromSdist`
|
||||
|
||||
Newer versions of [nixpkgs] provide `buildFromSdist` to build your package from the `cabal sdist` tarball. While this is disabled by default ([see here](https://github.com/srid/haskell-flake/pull/253)), you can enable it by setting `settings.<name>.buildFromSdist` to `true`.
|
||||
|
||||
|
||||
[nixpkgs]: https://nixos.asia/en/nixpkgs
|
@ -12,11 +12,6 @@
|
||||
}:
|
||||
|
||||
let
|
||||
# NOTE: We do not use the optimized version, `buildFromCabalSdist`, because it
|
||||
# breaks in some cases. See https://github.com/srid/haskell-flake/pull/220
|
||||
fromSdist = pkgs.haskell.lib.buildFromSdist or
|
||||
(log.traceWarning "Your nixpkgs does not have hs.buildFromSdist" (pkg: pkg));
|
||||
|
||||
mkNewStorePath = name: src:
|
||||
# Since 'src' may be a subdirectory of a store path
|
||||
# (in string form, which means that it isn't automatically
|
||||
@ -38,9 +33,4 @@ lib.pipe root
|
||||
|
||||
(root: self.callCabal2nix name root { })
|
||||
(x: log.traceDebug "${name}.cabal2nixDeriver ${x.cabal2nixDeriver.outPath}" x)
|
||||
|
||||
# Make sure all files we use are included in the sdist, as a check
|
||||
# for release-worthiness.
|
||||
fromSdist
|
||||
(x: log.traceDebug "${name}.fromSdist ${x.outPath}" x)
|
||||
]
|
||||
|
@ -84,6 +84,11 @@ in
|
||||
'';
|
||||
default =
|
||||
let
|
||||
globalSettings = {
|
||||
# We disable this by default because it causes breakage.
|
||||
# See https://github.com/srid/haskell-flake/pull/253
|
||||
buildFromSdist = lib.mkDefault false;
|
||||
};
|
||||
localSettings = { name, package, config, ... }:
|
||||
lib.optionalAttrs (package.local.toDefinedProject or false) {
|
||||
# Disabling haddock and profiling is mainly to speed up Nix builds.
|
||||
@ -91,7 +96,12 @@ in
|
||||
libraryProfiling = lib.mkDefault false; # Avoid double-compilation.
|
||||
};
|
||||
in
|
||||
if config.defaults.enable then localSettings else { };
|
||||
if config.defaults.enable then {
|
||||
imports = [
|
||||
globalSettings
|
||||
localSettings
|
||||
];
|
||||
} else { };
|
||||
};
|
||||
|
||||
projectModules.output = mkOption {
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
{ name, pkgs, lib, config, log, ... }:
|
||||
let
|
||||
inherit (lib) types;
|
||||
inherit (import ./lib.nix {
|
||||
@ -310,6 +310,20 @@ in
|
||||
'';
|
||||
impl = triggerRebuild;
|
||||
};
|
||||
buildFromSdist = {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to use `buildFromSdist` to build the package.
|
||||
Make sure all files we use are included in the sdist, as a check
|
||||
for release-worthiness.
|
||||
'';
|
||||
impl = enable:
|
||||
if enable then
|
||||
(pkg: lib.pipe pkg [
|
||||
buildFromSdist
|
||||
(x: log.traceDebug "${name}.buildFromSdist ${x.outPath}" x)
|
||||
]) else x: x;
|
||||
};
|
||||
|
||||
removeReferencesTo = {
|
||||
type = types.listOf types.package;
|
||||
|
@ -63,6 +63,7 @@ in
|
||||
];
|
||||
specialArgs = {
|
||||
inherit name pkgs self super;
|
||||
inherit (project.config) log;
|
||||
package = project.config.packages.${name} or null;
|
||||
} // (import ./lib.nix {
|
||||
inherit lib;
|
||||
|
Loading…
Reference in New Issue
Block a user