Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance by @bb010g #207

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dev/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@
};
});
};

# Make some non-standard flake outputs available for exploration in the REPL
# This isn't part of a proper flake anyway (see dev/flake.nix) so we may as
# well leave this on.
debug = true;
}
5 changes: 4 additions & 1 deletion lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ let
attrs@{ staticModules ? [ ] }: mkOptionType {
name = "deferredModule";
description = "module";
descriptionClass = "noun";
check = x: isAttrs x || isFunction x || path.check x;
merge = loc: defs: staticModules ++ map (def: lib.setDefaultModuleLocation "${def.file}, via option ${showOption loc}" def.value) defs;
merge = loc: defs: {
imports = staticModules ++ map (def: lib.setDefaultModuleLocation "${def.file}, via option ${showOption loc}" def.value) defs;
};
inherit (submoduleWith { modules = staticModules; })
getSubOptions
getSubModules;
Expand Down
4 changes: 3 additions & 1 deletion modules/apps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ let
};

getExe = 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"'')}";
"${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"''
)}";

appType = lib.types.submodule {
options = {
Expand Down
15 changes: 8 additions & 7 deletions modules/moduleWithSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@
let
system =
config._module.args.system or
config._module.args.pkgs.stdenv.hostPlatform.system or
(throw "moduleWithSystem: Could not determine the configuration's system parameter for this module system application.");
config._module.args.pkgs.stdenv.hostPlatform.system or (throw
"moduleWithSystem: Could not determine the `system` parameter for this module set evaluation."
);

allArgs = withSystem system (args: args);
allPerSystemArgs = withSystem system (args: args);

lazyArgsPerParameter = f: builtins.mapAttrs
(k: v: allArgs.${k} or (throw "moduleWithSystem: module argument `${k}` does not exist."))
lazyPerSystemArgsPerParameter = f: builtins.mapAttrs
(k: v: allPerSystemArgs.${k} or (throw "moduleWithSystem: per-system argument `${k}` does not exist."))
(builtins.functionArgs f);

# Use reflection to make the call lazy in the argument.
# Restricts args to the ones declared.
callLazily = f: a: f (lazyArgsPerParameter f);
callLazily = f: a: f (lazyPerSystemArgsPerParameter f);
in
{
imports = [
(callLazily module allArgs)
(callLazily module allPerSystemArgs)
];
};
};
Expand Down
6 changes: 4 additions & 2 deletions modules/nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
#
{
config = {
perSystem = { inputs', lib, ... }: {
perSystem = { inputs', lib, options, ... }: {
config = {
_module.args.pkgs = lib.mkOptionDefault (
builtins.seq
(inputs'.nixpkgs or (throw "flake-parts: The flake does not have a `nixpkgs` input. Please add it, or set `perSystem._module.args.pkgs` yourself."))
inputs'.nixpkgs or (throw
"flake-parts: The flake does not have a `nixpkgs` input. Please add it, or set `${options._module.args}.pkgs` yourself."
)
inputs'.nixpkgs.legacyPackages
);
};
Expand Down
4 changes: 2 additions & 2 deletions modules/perSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ in
_module.args.moduleWithSystem = throwAliasError "moduleWithSystem";
};
});
apply = modules: system:
apply = module: system:
(lib.evalModules {
inherit modules;
modules = [ module ];
prefix = [ "perSystem" system ];
specialArgs = {
inherit system;
Expand Down