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:
let
inherit (inputs) nixpkgs self zig2nix;
inherit (inputs) nixpkgs self;
lib = nixpkgs.lib.extend (import ./extended.nix);
inherit (builtins)

View file

@ -1,5 +1,6 @@
final: prev:
let
inherit (builtins) listToAttrs substring;
inherit (final)
concatStringsSep
hasSuffix
@ -8,9 +9,8 @@ let
mkOption
types
;
inherit (builtins) listToAttrs substring;
in
rec {
let
enabled = {
enable = true;
};
@ -37,13 +37,13 @@ rec {
}) attrs
);
isNixFile = path: hasSuffix ".nix" path;
mkIfIn = name: list: prev.mkIf (builtins.elem name list);
mkOizysModule = config: attr: content: {
options.oizys.${attr}.enable = mkEnableOption "enable ${attr} support";
config = mkIf config.oizys.${attr}.enable content;
};
mkDefaultOizysModule = config: attr: content: {
options.oizys.${attr}.enable = mkOption {
default = true;
@ -61,4 +61,19 @@ rec {
(substring 4 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, ... }:
let
inherit (builtins) filter;
inherit (lib)
isNixFile
mkOption
types
isNixFile
literalExpression
mdDoc
;
inherit (lib.filesystem) listFilesRecursive;
inherit (builtins) filter;
listNixFilesRecursive =
dir: filter (f: (f != ./default.nix) && (isNixFile f)) (listFilesRecursive dir);
in
{
imports = filter (f: (f != ./default.nix) && (isNixFile f)) (listFilesRecursive ./.);
imports = listNixFilesRecursive ./.;
options.oizys.languages = mkOption {
type = with types; (listOf str);
description = mdDoc ''