~dblsaiko/nix-extras

283d64b5c5a556c5fb0f017a18bef82213eb5cef — Marco Rebhan 6 months ago d88e09e
nix-pijul: Improve patch
1 files changed, 13 insertions(+), 10 deletions(-)

M packages/nix-pijul.nix
M packages/nix-pijul.nix => packages/nix-pijul.nix +13 -10
@@ 4,19 4,22 @@
  nix ? nixUnstable,
  nixUnstable,
}: let
  editScript = ''
    execute-keys "/while \(flakeRoot" <ret>
    execute-keys "/pathExists" <ret>
    execute-keys f{ <a-i> {xyp
    execute-keys <a-\;> wa "else " <esc> k <a-j>
    execute-keys f{ <a-i> {xs "git" <ret> c "pijul" <esc>
    execute-keys ),f{ <a-i> {s "shallow" <ret> <a-i> pdd
    write-quit
  '';
  editScript = lib.concatStringsSep "" [
    # locate section to patch
    "/std::pair<lt>FlakeRef, std::string> parseFlakeRefWithFragment<ret>"
    "/flakeRoot<ret>"
    "/pathExists<ret>"
    # duplicate if block
    "f{<a-i>{xyp<a-;>"
    # replace 'git' with 'pijul'
    "f{<a-i>{xsgit<ret>cpijul<esc>),"
    # remove shallow git repo handling
    "f{<a-i>{sshallow<ret><a-i>pd"
  ];
in
nix.overrideAttrs (self: {
  postPatch = self.postPatch or "" + ''
    ${kakoune}/bin/kak -ui dummy -e ${lib.escapeShellArg editScript} \
    ${kakoune}/bin/kak -ui dummy -f ${lib.escapeShellArg editScript} \
      src/libexpr/flake/flakeref.cc
  '';
})