mkRedundantOption
This commit is contained in:
1 file changed
+17
-7
@@ -5,8 +5,10 @@
|
|||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: rec {
|
outputs = { self, nixpkgs }: let
|
||||||
mkIfElse = with nixpkgs.lib; p: yes: no: mkMerge [
|
inherit (nixpkgs) lib;
|
||||||
|
in rec {
|
||||||
|
mkIfElse = with lib; p: yes: no: mkMerge [
|
||||||
(mkIf p yes)
|
(mkIf p yes)
|
||||||
(mkIf (!p) no)
|
(mkIf (!p) no)
|
||||||
];
|
];
|
||||||
@@ -20,9 +22,9 @@
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
attrByStrPath = strPath: set: nixpkgs.lib.attrByPath (nixpkgs.lib.strings.splitString "." strPath) null set;
|
attrByStrPath = strPath: set: lib.attrByPath (lib.strings.splitString "." strPath) null set;
|
||||||
|
|
||||||
setAttrByStrPath = strPath: value: nixpkgs.lib.setAttrByPath (nixpkgs.lib.strings.splitString "." strPath) value;
|
setAttrByStrPath = strPath: value: lib.setAttrByPath (lib.strings.splitString "." strPath) value;
|
||||||
|
|
||||||
homeFilesFromStringAttrs = { dir, attrs, exec ? false }: mergeListsToAttrs (map (x: "${dir}/${x}") (builtins.attrNames attrs)) (map (y: {
|
homeFilesFromStringAttrs = { dir, attrs, exec ? false }: mergeListsToAttrs (map (x: "${dir}/${x}") (builtins.attrNames attrs)) (map (y: {
|
||||||
text = y;
|
text = y;
|
||||||
@@ -37,11 +39,11 @@
|
|||||||
exec = true;
|
exec = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
mergeListsToAttrs = names: values: nixpkgs.lib.listToAttrs (nixpkgs.lib.zipListsWith (name: value: { inherit name value; }) names values);
|
mergeListsToAttrs = names: values: lib.listToAttrs (lib.zipListsWith (name: value: { inherit name value; }) names values);
|
||||||
|
|
||||||
mkEnumFromDirContents = dir: nixpkgs.lib.types.enum (map (name: nixpkgs.lib.removeSuffix ".nix" name) (builtins.attrNames (builtins.readDir dir)));
|
mkEnumFromDirContents = dir: lib.types.enum (map (name: lib.removeSuffix ".nix" name) (builtins.attrNames (builtins.readDir dir)));
|
||||||
|
|
||||||
mkOptionalListOfType = type: nixpkgs.lib.types.either (type) (nixpkgs.lib.types.listOf (type));
|
mkOptionalListOfType = type: lib.types.either (type) (lib.types.listOf (type));
|
||||||
|
|
||||||
mkMirroredModulesFlakeModule = moduleName: func: {
|
mkMirroredModulesFlakeModule = moduleName: func: {
|
||||||
flake.nixosModules.${moduleName} = func;
|
flake.nixosModules.${moduleName} = func;
|
||||||
@@ -50,5 +52,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
mkRedundantOptionDescription = name: value: "The functionality of this option completely depends on `${name}` being `${value}`, and will not be evaluated otherwise.";
|
mkRedundantOptionDescription = name: value: "The functionality of this option completely depends on `${name}` being `${value}`, and will not be evaluated otherwise.";
|
||||||
|
|
||||||
|
mkRedundantOption = name: value: attrs: lib.mkOption {
|
||||||
|
inherit (attrs) type default;
|
||||||
|
description = ''
|
||||||
|
${attrs.description}
|
||||||
|
${mkRedundantOptionDescription name value}
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user