Skip to content

Commit

Permalink
flake: list deprecated args in throw
Browse files Browse the repository at this point in the history
The use of `throwIf` was retained on the off chance that someone
intentionally overrides it.
  • Loading branch information
aameen-tulip authored and rycee committed Sep 27, 2022
1 parent 1f5ef2b commit 6dc8a43
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,37 @@
, configuration ? null, extraModules ? null, stateVersion ? null
, username ? null, homeDirectory ? null, system ? null }@args:
let
throwForRemovedArg = v:
lib.throwIf (v != null) ''
The 'homeManagerConfiguration' arguments
msgForRemovedArg = ''
The 'homeManagerConfiguration' arguments
- 'configuration',
- 'username',
- 'homeDirectory'
- 'stateVersion',
- 'extraModules', and
- 'system'
- 'configuration',
- 'username',
- 'homeDirectory'
- 'stateVersion',
- 'extraModules', and
- 'system'
have been removed. Instead use the arguments 'pkgs' and
'modules'. See the 22.11 release notes for more.
'';
have been removed. Instead use the arguments 'pkgs' and
'modules'. See the 22.11 release notes for more.
'';

throwForRemovedArgs = v:
let
used = builtins.filter (n: (args.${n} or null) != null) [
"configuration"
"username"
"homeDirectory"
"stateVersion"
"extraModules"
"system"
];
msg = msgForRemovedArg + ''
Deprecated args passed: ''
+ builtins.concatStringsSep " " used;
in lib.throwIf (used != [ ]) msg v;

throwForRemovedArgs = throwForRemovedArg configuration # \
throwForRemovedArg username # \
throwForRemovedArg homeDirectory # \
throwForRemovedArg stateVersion # \
throwForRemovedArg extraModules # \
throwForRemovedArg system;
in throwForRemovedArgs (import ./modules {
inherit pkgs lib check extraSpecialArgs;
configuration = { ... }: {
Expand Down

0 comments on commit 6dc8a43

Please sign in to comment.