mirror of
https://github.com/nix-community/home-manager
synced 2024-12-02 16:09:46 +01:00
nushell: Simplify file creation
This commit is contained in:
parent
2cacdd6a27
commit
c41e54ac3d
1 changed files with 26 additions and 27 deletions
|
@ -157,37 +157,36 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.file = mkMerge [
|
home.file."${configDir}/config.nu" = let
|
||||||
(let
|
writeConfig = cfg.configFile != null || cfg.extraConfig != ""
|
||||||
writeConfig = cfg.configFile != null || cfg.extraConfig != ""
|
|| aliasesStr != "";
|
||||||
|| aliasesStr != "";
|
aliasesStr = concatStringsSep "\n"
|
||||||
|
(mapAttrsToList (k: v: "alias ${k} = ${v}") cfg.shellAliases);
|
||||||
|
in mkIf writeConfig {
|
||||||
|
text = mkMerge [
|
||||||
|
(mkIf (cfg.configFile != null) cfg.configFile.text)
|
||||||
|
cfg.extraConfig
|
||||||
|
aliasesStr
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
aliasesStr = concatStringsSep "\n"
|
home.file."${configDir}/env.nu" = let
|
||||||
(mapAttrsToList (k: v: "alias ${k} = ${v}") cfg.shellAliases);
|
envVarsStr = concatStringsSep "\n"
|
||||||
in mkIf writeConfig {
|
(mapAttrsToList (k: v: "$env.${k} = ${v}") cfg.environmentVariables);
|
||||||
"${configDir}/config.nu".text = mkMerge [
|
in mkIf (cfg.envFile != null || cfg.extraEnv != "" || envVarsStr != "") {
|
||||||
(mkIf (cfg.configFile != null) cfg.configFile.text)
|
text = mkMerge [
|
||||||
cfg.extraConfig
|
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
||||||
aliasesStr
|
cfg.extraEnv
|
||||||
];
|
envVarsStr
|
||||||
})
|
];
|
||||||
|
};
|
||||||
|
|
||||||
(let
|
home.file."${configDir}/login.nu" =
|
||||||
envVarsStr = concatStringsSep "\n"
|
mkIf (cfg.loginFile != null || cfg.extraLogin != "") {
|
||||||
(mapAttrsToList (k: v: "$env.${k} = ${v}") cfg.environmentVariables);
|
text = mkMerge [
|
||||||
in mkIf (cfg.envFile != null || cfg.extraEnv != "" || envVarsStr != "") {
|
|
||||||
"${configDir}/env.nu".text = mkMerge [
|
|
||||||
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
|
||||||
cfg.extraEnv
|
|
||||||
envVarsStr
|
|
||||||
];
|
|
||||||
})
|
|
||||||
(mkIf (cfg.loginFile != null || cfg.extraLogin != "") {
|
|
||||||
"${configDir}/login.nu".text = mkMerge [
|
|
||||||
(mkIf (cfg.loginFile != null) cfg.loginFile.text)
|
(mkIf (cfg.loginFile != null) cfg.loginFile.text)
|
||||||
cfg.extraLogin
|
cfg.extraLogin
|
||||||
];
|
];
|
||||||
})
|
};
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue