diff --git a/lib/files.ncl b/lib/files.ncl index 6a037fa1..1888a9b1 100644 --- a/lib/files.ncl +++ b/lib/files.ncl @@ -83,14 +83,16 @@ let nix = import "./nix-interop/nix.ncl" in file_descr.materialisation_method in nix-s%" - rm -f %{target} - echo "Regenerating %{target}" - target_dir=$(dirname %{target}) - test "${target_dir}" != "." && mkdir -p "${target_dir}" - # XXX: If `source.file` is set explicitely to a relative path - # and `materialisation_method` is `'Symlink`, this will link to the - # original file, not one in the store. Not sure that's what we want. - %{copy_command} %{file_descr.file} %{target} + if [[ ! -f "%{target}" ]] || [[ $(cat "%{target}") != $(cat "%{file_descr.file}") ]]; then + echo "Regenerating %{target}" + rm -f %{target} + target_dir=$(dirname "%{target}") + test "${target_dir}" != "." && mkdir -p "${target_dir}" + # XXX: If `source.file` is set explicitely to a relative path + # and `materialisation_method` is `'Symlink`, this will link to the + # original file, not one in the store. Not sure that's what we want. + %{copy_command} "%{file_descr.file}" "%{target}" + fi "% in {