Guest User

Untitled

a guest
Jan 9th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. Links the bookmark file into the users local surfraw configuration.
  2. #If the file already exists, force overwrite only if symlinked files hash
  3. #matches the already existing file.
  4. home.activation.linkSurfrawBookmarkFile = let
  5. placeholderBookmarkFile = pkgs.buildPackages.writeText
  6. "surfraw-placeholder-bookmarks" ''
  7. # This is a readonly, example bookmark file generated by home-manager.
  8. # If you want your own bookmarks here, use the 'linkBookmarkFile'
  9. # option of the surfraw module. This example file will then be replaced
  10. # by a link to your specified bookmark file.
  11. #
  12. # Bookmark Format
  13. # ---------------
  14. #
  15. # Everything after a # is treated as comment until the end of line.
  16. # Bookmarks are given in following form.
  17. # <name><whitespace><url> #And possible some tags as a comment
  18. # ntk http://www.ntk.net/
  19. '';
  20. source = if cfg.linkBookmarkFile == null
  21. then placeholderBookmarkFile else toString cfg.linkBookmarkFile;
  22. target = "${config.xdg.configHome}/surfraw/bookmarks";
  23. hashOf = file: builtins.hashFile "sha256" file;
  24. isSourceAlsoTarget = hashOf source == hashOf target;
  25. isTargetPlaceholder = hashOf target == hashOf placeholderBookmarkFile;
  26. in lib.hm.dag.entryAfter ["writeBoundary"]
  27. (if !(pathExists target) || isTargetPlaceholder || isSourceAlsoTarget
  28. then "$DRY_RUN_CMD ln -s -f $VERBOSE_ARG ${source} ${target}"
  29. else "$DRY_RUN_CMD ln -s $VERBOSE_ARG ${source} ${target}");
Advertisement
Add Comment
Please, Sign In to add comment