mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 10:10:45 -06:00
refactoring
This commit is contained in:
parent
506e9abcee
commit
02d34a6aae
3 changed files with 25 additions and 8 deletions
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 ''
|
||||||
|
|
Loading…
Reference in a new issue