add new external flake to provide helper functions
This commit is contained in:
18 files changed
+73
-163
No files matched your search
@@ -1,69 +0,0 @@
|
||||
{ inputs, self, ... }: {
|
||||
flake.nixosModules.global = { pkgs, config, lib, ... }: {
|
||||
options.helpers = {
|
||||
typeOf = lib.mkOption {
|
||||
type = lib.types.functionTo lib.types.str;
|
||||
default = value: (
|
||||
if builtins.isAttrs value then "attrs" else (
|
||||
if builtins.isBool value then "bool" else (
|
||||
if builtins.isFloat value then "float" else (
|
||||
if builtins.isFunction value then "function" else (
|
||||
if builtins.isInt value then "int" else (
|
||||
if builtins.isList value then "list" else (
|
||||
if builtins.isPath value then "path" else (
|
||||
if builtins.isString value then "str" else ""
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
attrByStrPath = lib.mkOption {
|
||||
default = strPath: set:
|
||||
lib.attrsets.attrByPath (lib.strings.splitString "." strPath) null set;
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
homeManagerInheritEnableOptionElse = lib.mkOption {
|
||||
# type = lib.types.functionTo lib.types.attrs;
|
||||
default = optionName: systemAttrs: let
|
||||
mkIfElse = with lib; p: yes: no: mkMerge [
|
||||
(mkIf p yes)
|
||||
(mkIf (!p) no)
|
||||
];
|
||||
|
||||
attrByStrPath = strPath: set:
|
||||
lib.attrsets.attrByPath (lib.strings.splitString "." strPath) null set;
|
||||
|
||||
setAttrByStrPath = strPath: value:
|
||||
lib.attrsets.setAttrByPath (lib.strings.splitString "." strPath) value;
|
||||
in builtins.trace "hi" lib.mkIf (attrByStrPath optionName config) (mkIfElse (config.features.nixos.home-manager.enable) {
|
||||
home-manager.sharedModules = [
|
||||
({ lib, ... }: (setAttrByStrPath optionName (lib.mkDefault true)))
|
||||
];
|
||||
} (systemAttrs));
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeModules.global = { pkgs, config, lib, ... }: {
|
||||
options.helpers = {
|
||||
mkSymlinkActivationScript = lib.mkOption {
|
||||
type = lib.types.functionTo lib.types.str;
|
||||
default = {target, source, isDir ? false}: ''
|
||||
if [ ${if isDir then "-d" else "-f"} /home/grey/${target} ]; then
|
||||
rm${if isDir then " -rf" else ""} /home/grey/${target}
|
||||
fi
|
||||
ln -s ${config.info.rootPath}/${source} /home/grey/${target}
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -83,8 +83,12 @@
|
||||
};
|
||||
|
||||
home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) {
|
||||
info.isStandalone = lib.mkDefault false;
|
||||
# home.stateVersion = lib.mkDefault config.info.stateVersion;
|
||||
info = {
|
||||
rootPath = lib.mkDefault config.info.rootPath;
|
||||
hostName = lib.mkDefault config.info.hostName;
|
||||
stateVersion = lib.mkDefault config.info.stateVersion;
|
||||
isStandalone = lib.mkDefault false;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user