style(flake)!: manually import lib flake module

- Also make `lib` an `internal` option
- Unify let blocks and move them under `imports`
  (makes it clear where `config.lib` comes from)
- Fix a minor typo
This commit is contained in:
reo101 2024-09-07 20:49:14 +03:00
parent 1baef9b78c
commit 31f9e7dbef
Signed by: reo101
GPG key ID: 675AA7EF13964ACB
9 changed files with 96 additions and 82 deletions

View file

@ -5,9 +5,9 @@ let
and and
hasFiles hasFiles
hasDirectories hasDirectories
configuration-type-to-outputs-modules; configuration-type-to-outputs-modules
in ;
let
# `pkgs` with flake's overlays # `pkgs` with flake's overlays
# NOTE: done here to avoid infinite recursion # NOTE: done here to avoid infinite recursion
pkgs' = system: pkgs' = system:

View file

@ -1,21 +1,19 @@
{ lib, config, self, inputs, withSystem, ... }: { lib, config, self, inputs, withSystem, ... }:
let
inherit (config.lib)
and
hasFiles
hasDirectories
recurseDir
kebabToCamel
configuration-type-to-outputs-modules;
in
{ {
imports = [ imports = [
../lib
./default-generators.nix ./default-generators.nix
]; ];
options = let options = let
inherit (lib) types; inherit (lib)
types
;
inherit (config.lib)
recurseDir
kebabToCamel
;
in { in {
auto.configurations = lib.mkOption { auto.configurations = lib.mkOption {
description = '' description = ''

View file

@ -6,9 +6,12 @@
]; ];
options = let options = let
inherit (lib) types; inherit (lib)
types
;
in { in {
lib = lib.mkOption { lib = lib.mkOption {
internal = true;
type = types.unspecified; type = types.unspecified;
}; };
}; };

View file

@ -1,14 +1,13 @@
{ lib, config, self, inputs, ... }: { lib, config, self, inputs, ... }:
let {
config.lib = let
inherit (config.lib) inherit (config.lib)
and and
eq eq
hasFiles hasFiles
; ;
in in rec {
{
config.lib = rec {
# Try to passthru `inputs` by default # Try to passthru `inputs` by default
defaultThingHandle = { raw, thingType }: name: result: let defaultThingHandle = { raw, thingType }: name: result: let
thing = thing =

View file

@ -1,21 +1,24 @@
{ lib, config, self, inputs, ... }: { lib, config, self, inputs, ... }:
let {
imports = [
../lib
];
options = let
inherit (lib)
types
;
inherit (config.lib) inherit (config.lib)
createThings createThings
kebabToCamel; kebabToCamel
in ;
let
# Modules helpers
createModules = baseDir: createModules = baseDir:
createThings { createThings {
inherit baseDir; inherit baseDir;
thingType = "module"; thingType = "module";
}; };
in
{
options = let
inherit (lib) types;
in { in {
auto.modules = lib.mkOption { auto.modules = lib.mkOption {
description = '' description = ''
@ -76,7 +79,6 @@ in
(createModules dir); (createModules dir);
}; };
}; };
config = {};
})); }));
# TODO: put in a more visible place # TODO: put in a more visible place
default = { default = {

View file

@ -1,19 +1,23 @@
{ lib, config, self, inputs, ... }: { lib, config, self, inputs, ... }:
let {
imports = [
../lib
];
options = let
inherit (lib)
types
;
inherit (config.lib) inherit (config.lib)
createThings; createThings
in ;
let
createOverlays = baseDir: createOverlays = baseDir:
createThings { createThings {
inherit baseDir; inherit baseDir;
thingType = "overlay"; thingType = "overlay";
}; };
in
{
options = let
inherit (lib) types;
in { in {
auto.overlays = lib.mkOption { auto.overlays = lib.mkOption {
description = '' description = ''

View file

@ -1,10 +1,18 @@
{ lib, config, self, inputs, ... }: { lib, config, self, inputs, ... }:
let {
imports = [
../lib
];
options = let
inherit (lib)
types
;
inherit (config.lib) inherit (config.lib)
createThings; createThings
in ;
let
createPackages = baseDir: createPackages = baseDir:
createThings { createThings {
inherit baseDir; inherit baseDir;
@ -14,10 +22,6 @@ let
default = lib.const true; default = lib.const true;
}; };
}; };
in
{
options = let
inherit (lib) types;
in { in {
auto.packages = lib.mkOption { auto.packages = lib.mkOption {
description = '' description = ''

View file

@ -4,7 +4,7 @@
perSystem = { system, ... }: { perSystem = { system, ... }: {
_module.args.pkgs = import inputs.nixpkgs { _module.args.pkgs = import inputs.nixpkgs {
inherit system; inherit system;
# WARN: not including `self.packages` overylay # WARN: not including `self.packages` overlay
# because it causes an infinite recursion # because it causes an infinite recursion
overlays = lib.attrValues self.overlays ++ [ overlays = lib.attrValues self.overlays ++ [
inputs.neovim-nightly-overlay.overlays.default inputs.neovim-nightly-overlay.overlays.default

View file

@ -1,10 +1,18 @@
{ lib, config, self, inputs, ... }: { lib, config, self, inputs, ... }:
let {
imports = [
../lib
];
options = let
inherit (lib)
types
;
inherit (config.lib) inherit (config.lib)
createThings; createThings
in ;
let
createDevShells = baseDir: createDevShells = baseDir:
createThings { createThings {
inherit baseDir; inherit baseDir;
@ -14,10 +22,6 @@ let
default = lib.const true; default = lib.const true;
}; };
}; };
in
{
options = let
inherit (lib) types;
in { in {
auto.devShells = lib.mkOption { auto.devShells = lib.mkOption {
description = '' description = ''