Skip to content

Instantly share code, notes, and snippets.

@tomberek
Created March 15, 2022 14:50
Show Gist options
  • Save tomberek/eb6c19b1b28ee8becc0d602e7428f2fd to your computer and use it in GitHub Desktop.
Save tomberek/eb6c19b1b28ee8becc0d602e7428f2fd to your computer and use it in GitHub Desktop.
default = {
type = "app";
program = with args.unstable.legacyPackages.x86_64-linux;
(writeShellApplication {
name = "hash-me.sh";
runtimeInputs = [coreutils];
text = ''
self=$(echo ${self.outPath} | cut -d/ -f4)
rev=${builtins.toString (self.revCount or 0)}
lastMod=${builtins.toString (self.lastModified or 0)}
echo "$self" >&2
hash=$(printf "%s;%s;%d;%d;%s" "$self" "" "$rev" "$lastMod" "$(cat ${self.outPath}/flake.lock)" | sha256sum | cut -d' ' -f1)
printf "$HOME/.cache/nix/eval-cache-v2/%s.sqlite\n" "$hash"
'';
})
+ "/bin/hash-me.sh";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment