modules/system: flatten
This commit is contained in:
parent
52c84814e8
commit
5c3f1dac68
14 changed files with 65 additions and 70 deletions
51
modules/system/flake-qol.nix
Normal file
51
modules/system/flake-qol.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ perInput }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.settei.flake-qol;
|
||||
in
|
||||
{
|
||||
_file = ./flake-qol.nix;
|
||||
|
||||
options.settei.flake-qol = with lib; {
|
||||
enable = mkEnableOption "QoL defaults when using flakes" // {
|
||||
default = true;
|
||||
};
|
||||
reexportAsArgs = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
inputs = mkOption { type = types.unspecified; };
|
||||
inputs-flakes = mkOption {
|
||||
type = types.attrs;
|
||||
readOnly = true;
|
||||
};
|
||||
inputs' = mkOption {
|
||||
type = types.attrs;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
reexportedArgs = lib.mkIf cfg.reexportAsArgs { inherit (cfg) inputs inputs-flakes inputs'; };
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
settei.flake-qol = {
|
||||
inputs-flakes = lib.filterAttrs (_: input: input ? flake -> input.flake) cfg.inputs;
|
||||
inputs' = lib.mapAttrs (_: perInput pkgs.stdenv.system) cfg.inputs-flakes;
|
||||
};
|
||||
|
||||
_module.args = reexportedArgs;
|
||||
settei.user.extraArgs = reexportedArgs;
|
||||
|
||||
nix = {
|
||||
registry = lib.mapAttrs (_: flake: { inherit flake; }) cfg.inputs-flakes;
|
||||
nixPath = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue