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
hasFiles
hasDirectories
configuration-type-to-outputs-modules;
in
let
configuration-type-to-outputs-modules
;
# `pkgs` with flake's overlays
# NOTE: done here to avoid infinite recursion
pkgs' = system:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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