add function to mirror system config in home config
This commit is contained in:
10 files changed
+69
-20
No files matched your search
@@ -1,11 +1,37 @@
|
||||
{ inputs, self, ... }: {
|
||||
flake.nixosModules.global = { pkgs, config, lib, ... }: {
|
||||
options.helpers = {
|
||||
# nothing here yet
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeModules.global = { pkgs, config, lib, ... }: {
|
||||
flake.homeModules.global = { pkgs, config, osConfig, lib, ... }: {
|
||||
options.helpers = {
|
||||
mkSymlinkActivationScript = lib.mkOption {
|
||||
type = lib.types.functionTo lib.types.str;
|
||||
@@ -15,6 +41,19 @@
|
||||
fi
|
||||
ln -s ${config.info.rootPath}/${source} /home/grey/${target}
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
inheritOsConfigToHome = lib.mkOption {
|
||||
type = lib.types.functionTo lib.types.attrs;
|
||||
default = let
|
||||
safeOsConfig = builtins.tryEval osConfig;
|
||||
in option: {
|
||||
type = if safeOsConfig.success then safeOsConfig.value.helpers.attrByStrPath (safeOsConfig.value.helpers.typeOf (safeOsConfig.value.helpers.attrByStrPath option safeOsConfig.value)) lib.types else null;
|
||||
default = (lib.mkIf (safeOsConfig.success) (safeOsConfig.value.helpers.attrByStrPath option safeOsConfig.value)).content;
|
||||
readOnly = true;
|
||||
};
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user