Use overlay

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-08-17 19:57:22 +03:00
parent 37d2ba1946
commit 10930e85d6
9 changed files with 26 additions and 40 deletions

View File

@@ -0,0 +1,11 @@
final: prev:
"${
prev.writeShellApplication {
name = "merge-key-value";
runtimeInputs = with final; [
coreutils
gawk
];
text = builtins.readFile ./key-value.sh;
}
}/bin/merge-key-value"

View File

@@ -0,0 +1,15 @@
# shellcheck shell=bash
source=$(realpath -m "$1")
target=$(realpath -m "$2")
if [[ -f "$target" ]]; then
temp=$(mktemp)
awk -F '=' 'NR==FNR{a[$1]=$0;next}($1 in a){$0=a[$1]}1' "$source" "$target" > "$temp"
mv "$temp" "$target"
else
mkdir -p "$(dirname "$target")"
cp "$source" "$target"
fi
echo "Configuration file $target has been updated."