refactoring

This commit is contained in:
Daylin Morgan 2024-06-25 16:03:50 -05:00
parent 506e9abcee
commit 02d34a6aae
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 25 additions and 8 deletions

View file

@ -1,6 +1,6 @@
inputs: inputs:
let let
inherit (inputs) nixpkgs self zig2nix; inherit (inputs) nixpkgs self;
lib = nixpkgs.lib.extend (import ./extended.nix); lib = nixpkgs.lib.extend (import ./extended.nix);
inherit (builtins) inherit (builtins)

View file

@ -1,5 +1,6 @@
final: prev: final: prev:
let let
inherit (builtins) listToAttrs substring;
inherit (final) inherit (final)
concatStringsSep concatStringsSep
hasSuffix hasSuffix
@ -8,9 +9,8 @@ let
mkOption mkOption
types types
; ;
inherit (builtins) listToAttrs substring;
in in
rec { let
enabled = { enabled = {
enable = true; enable = true;
}; };
@ -37,13 +37,13 @@ rec {
}) attrs }) attrs
); );
isNixFile = path: hasSuffix ".nix" path;
mkIfIn = name: list: prev.mkIf (builtins.elem name list); mkIfIn = name: list: prev.mkIf (builtins.elem name list);
mkOizysModule = config: attr: content: { mkOizysModule = config: attr: content: {
options.oizys.${attr}.enable = mkEnableOption "enable ${attr} support"; options.oizys.${attr}.enable = mkEnableOption "enable ${attr} support";
config = mkIf config.oizys.${attr}.enable content; config = mkIf config.oizys.${attr}.enable content;
}; };
mkDefaultOizysModule = config: attr: content: { mkDefaultOizysModule = config: attr: content: {
options.oizys.${attr}.enable = mkOption { options.oizys.${attr}.enable = mkOption {
default = true; default = true;
@ -61,4 +61,19 @@ rec {
(substring 4 2 longDate) (substring 4 2 longDate)
(substring 6 2 longDate) (substring 6 2 longDate)
]); ]);
isNixFile = path: hasSuffix ".nix" path;
in
{
inherit
enabled
disabled
enableAttrs
disableAttrs
mkOizysModule
mkDefaultOizysModule
mkDate
isNixFile
mkIfIn
;
} }

View file

@ -1,18 +1,20 @@
{ lib, ... }: { lib, ... }:
let let
inherit (builtins) filter;
inherit (lib) inherit (lib)
isNixFile
mkOption mkOption
types types
isNixFile
literalExpression literalExpression
mdDoc mdDoc
; ;
inherit (lib.filesystem) listFilesRecursive; inherit (lib.filesystem) listFilesRecursive;
inherit (builtins) filter;
listNixFilesRecursive =
dir: filter (f: (f != ./default.nix) && (isNixFile f)) (listFilesRecursive dir);
in in
{ {
imports = filter (f: (f != ./default.nix) && (isNixFile f)) (listFilesRecursive ./.); imports = listNixFilesRecursive ./.;
options.oizys.languages = mkOption { options.oizys.languages = mkOption {
type = with types; (listOf str); type = with types; (listOf str);
description = mdDoc '' description = mdDoc ''