commit
250481aafe
4 changed files with 68 additions and 19 deletions
20
ChangeLog.md
20
ChangeLog.md
|
|
@ -1,4 +1,24 @@
|
|||
|
||||
# 2026-01-05
|
||||
|
||||
- Deprecated `mkSubmoduleOptions`. Declare options directly instead, e.g.
|
||||
`options.flake.foo = mkOption { ... }`. This works since Nixpkgs 22.05.
|
||||
|
||||
- Deprecated `mkDeferredModuleType` and `mkDeferredModuleOption`. Use
|
||||
`mkPerSystemType` and `mkPerSystemOption` respectively for `perSystem`
|
||||
type-merging. For other uses, use Nixpkgs' `types.deferredModuleWith`.
|
||||
|
||||
Note: flake-parts' implementation returns a list on merge, whereas Nixpkgs'
|
||||
returns a single module. Add `apply = m: [ m ];` to your option if you need
|
||||
the list behavior.
|
||||
|
||||
# 2024-05-16
|
||||
|
||||
- **Breaking**: Minimum supported Nixpkgs lib version is now 23.05 (was 22.05),
|
||||
due to the use of the `class` argument in `evalModules`.
|
||||
|
||||
- Add `class` to `evalModules` calls for imports "type checking".
|
||||
|
||||
# 2023-05-30
|
||||
|
||||
- Fix a strictness issue in `perInput`, affecting `inputs'`, `self'`.
|
||||
|
|
|
|||
56
lib.nix
56
lib.nix
|
|
@ -32,8 +32,22 @@ let
|
|||
then maybeFlake._type == "flake"
|
||||
else maybeFlake ? inputs && maybeFlake ? outputs && maybeFlake ? sourceInfo;
|
||||
|
||||
# Polyfill https://github.com/NixOS/nixpkgs/pull/163617
|
||||
deferredModuleWith = lib.deferredModuleWith or (
|
||||
/**
|
||||
Deprecated for any use except type-merging into `perSystem`.
|
||||
Use `lib.types.deferredModuleWith` instead, and add `apply = m: [ m ];` if needed.
|
||||
|
||||
The deferredModule type was pioneered in flake-parts for the `perSystem` option.
|
||||
The Nixpkgs version has an improved merge function that returns a single module,
|
||||
whereas this version returns a list. The flake-parts version was not updated to
|
||||
match this improvement in Nixpkgs.
|
||||
|
||||
# History
|
||||
|
||||
This predates `lib.types.deferredModuleWith`, added in Nixpkgs 22.11
|
||||
(https://github.com/NixOS/nixpkgs/pull/163617).
|
||||
Documented as deprecated in flake-parts in January 2026.
|
||||
*/
|
||||
deferredModuleWith =
|
||||
attrs@{ staticModules ? [ ] }: mkOptionType {
|
||||
name = "deferredModule";
|
||||
description = "module";
|
||||
|
|
@ -54,8 +68,14 @@ let
|
|||
staticModules = lhs.staticModules ++ rhs.staticModules;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
# Internal: preserves legacy list-merge behavior for perSystem type-merging.
|
||||
mkLegacyDeferredModuleType =
|
||||
module:
|
||||
deferredModuleWith {
|
||||
staticModules = [ module ];
|
||||
};
|
||||
|
||||
errorExample = ''
|
||||
For example:
|
||||
|
|
@ -169,18 +189,32 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
mkDeferredModuleType =
|
||||
module:
|
||||
deferredModuleWith {
|
||||
staticModules = [ module ];
|
||||
};
|
||||
mkPerSystemType = mkDeferredModuleType;
|
||||
/**
|
||||
Deprecated. Use mkPerSystemType/mkPerSystemOption for `perSystem` type-merging, or
|
||||
use Nixpkgs `types.deferredModule` directly, noting the lack of list wrapping;
|
||||
see `deferredModuleWith` docs.
|
||||
*/
|
||||
mkDeferredModuleType = mkLegacyDeferredModuleType;
|
||||
|
||||
/**
|
||||
Given a module, construct an option type suitable for type-merging into `perSystem`'s type.
|
||||
*/
|
||||
mkPerSystemType = mkLegacyDeferredModuleType;
|
||||
|
||||
/**
|
||||
Deprecated. Use mkPerSystemOption for `perSystem` type-merging, or
|
||||
use `mkOption` and Nixpkgs `types.deferredModule` directly, noting the
|
||||
lack of list wrapping; see `deferredModuleWith` docs.
|
||||
*/
|
||||
mkDeferredModuleOption =
|
||||
module:
|
||||
mkOption {
|
||||
type = flake-parts-lib.mkPerSystemType module;
|
||||
};
|
||||
|
||||
/**
|
||||
Given a module, construct an option declaration suitable for merging into the core `perSystem` module.
|
||||
*/
|
||||
mkPerSystemOption = mkDeferredModuleOption;
|
||||
|
||||
# Polyfill https://github.com/NixOS/nixpkgs/pull/344216
|
||||
|
|
@ -268,7 +302,7 @@ let
|
|||
|
||||
# A best effort, lenient estimate. Please use a recent nixpkgs lib if you
|
||||
# override it at all.
|
||||
minVersion = "22.05";
|
||||
minVersion = "23.05pre-git";
|
||||
|
||||
in
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,7 @@ let
|
|||
mkTransposedPerSystemModule
|
||||
;
|
||||
|
||||
getExe = lib.getExe or (
|
||||
x:
|
||||
"${lib.getBin x}/bin/${x.meta.mainProgram or (throw ''Package ${x.name or ""} does not have meta.mainProgram set, so I don't know how to find the main executable. You can set meta.mainProgram, or pass the full path to executable, e.g. program = "''${pkg}/bin/foo"'')}"
|
||||
);
|
||||
|
||||
programType = lib.types.coercedTo derivationType getExe lib.types.str;
|
||||
programType = lib.types.coercedTo derivationType lib.getExe lib.types.str;
|
||||
|
||||
derivationType = lib.types.package // {
|
||||
check = lib.isDerivation;
|
||||
|
|
@ -56,7 +51,7 @@ mkTransposedPerSystemModule {
|
|||
description = ''
|
||||
Programs runnable with nix run `<name>`.
|
||||
'';
|
||||
example = lib.literalExpression or lib.literalExample ''
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
default.program = "''${config.packages.hello}/bin/hello";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ in
|
|||
# This eta expansion exists for the sole purpose of making nix flake check happy.
|
||||
apply = lib.mapAttrs (_k: f: final: prev: f final prev);
|
||||
default = { };
|
||||
example = lib.literalExpression or lib.literalExample ''
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
default = final: prev: {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue