Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
44 lines
1.4 KiB
Nix
44 lines
1.4 KiB
Nix
# Updates the vscode setting file base on a nix expression
|
|
# should run from the workspace root.
|
|
{
|
|
writeShellScriptBin,
|
|
lib,
|
|
jq,
|
|
}:
|
|
##User Input
|
|
{
|
|
settings ? { },
|
|
# if marked as true will create an empty json file if does not exist
|
|
createIfDoesNotExists ? true,
|
|
vscodeSettingsFile ? ".vscode/settings.json",
|
|
userSettingsFolder ? "",
|
|
symlinkFromUserSetting ? false,
|
|
}:
|
|
let
|
|
|
|
updateVSCodeSettingsCmd = ''
|
|
(
|
|
echo 'updateSettings.nix: Updating ${vscodeSettingsFile}...'
|
|
oldSettings=$(cat ${vscodeSettingsFile})
|
|
echo $oldSettings' ${builtins.toJSON settings}' | ${jq}/bin/jq -s add > ${vscodeSettingsFile}
|
|
)'';
|
|
|
|
createEmptySettingsCmd = ''mkdir -p .vscode && echo "{}" > ${vscodeSettingsFile}'';
|
|
fileName = baseNameOf vscodeSettingsFile;
|
|
symlinkFromUserSettingCmd = lib.optionalString symlinkFromUserSetting ''&& mkdir -p "${userSettingsFolder}" && ln -sfv "$(pwd)/${vscodeSettingsFile}" "${userSettingsFolder}/" '';
|
|
in
|
|
|
|
writeShellScriptBin ''vscodeNixUpdate-${lib.removeSuffix ".json" fileName}'' (
|
|
lib.optionalString (settings != { }) (
|
|
if createIfDoesNotExists then
|
|
''
|
|
[ ! -f "${vscodeSettingsFile}" ] && ${createEmptySettingsCmd}
|
|
${updateVSCodeSettingsCmd} ${symlinkFromUserSettingCmd}
|
|
''
|
|
else
|
|
''
|
|
[ -f "${vscodeSettingsFile}" ] && ${updateVSCodeSettingsCmd} ${symlinkFromUserSettingCmd}
|
|
''
|
|
)
|
|
)
|