~dblsaiko/nix-extras

d88e09e5e89509241bdc47cf4009a91ffa3a1815 — Marco Rebhan 1 year, 8 days ago 28b717d
nix-pijul: Replace diff with hopefully more robust patch
4 files changed, 23 insertions(+), 56 deletions(-)

M packages/default.nix
A packages/nix-pijul.nix
D packages/nix-pijul/0011-Detect-Pijul-repositories-for-flake-paths.patch
D packages/nix-pijul/default.nix
M packages/default.nix => packages/default.nix +1 -1
@@ 12,7 12,7 @@ in {
  ksysguard = callPackage ./ksysguard {};
  louvre = callPackage ./louvre.nix {};
  netmuxd = callPackage ./netmuxd {};
  nix-pijul = callPackage ./nix-pijul {};
  nix-pijul = callPackage ./nix-pijul.nix {};
  nix-plugin-pijul = callPackage ./nix-plugin-pijul.nix {};
  plastik = callPackage ./plastik.nix {};
  plastikstyle = callPackage ./plastikstyle.nix {};

A packages/nix-pijul.nix => packages/nix-pijul.nix +22 -0
@@ 0,0 1,22 @@
{
  lib,
  kakoune,
  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
  '';
in
nix.overrideAttrs (self: {
  postPatch = self.postPatch or "" + ''
    ${kakoune}/bin/kak -ui dummy -e ${lib.escapeShellArg editScript} \
      src/libexpr/flake/flakeref.cc
  '';
})

D packages/nix-pijul/0011-Detect-Pijul-repositories-for-flake-paths.patch => packages/nix-pijul/0011-Detect-Pijul-repositories-for-flake-paths.patch +0 -44
@@ 1,44 0,0 @@
From 5f360b97aaf18af190bebb188615416e93150ddd Mon Sep 17 00:00:00 2001
From: Marco Rebhan <me@dblsaiko.net>
Date: Sun, 26 Nov 2023 01:25:17 +0100
Subject: [PATCH 11/12] Detect Pijul repositories for flake paths

---
 src/libexpr/flake/flakeref.cc | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/libexpr/flake/flakeref.cc b/src/libexpr/flake/flakeref.cc
index e1bce90bc..204fc839f 100644
--- a/src/libexpr/flake/flakeref.cc
+++ b/src/libexpr/flake/flakeref.cc
@@ -175,6 +175,27 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
                         if (pathExists(flakeRoot + "/.git/shallow"))
                             parsedURL.query.insert_or_assign("shallow", "1");
 
+                        return std::make_pair(
+                            FlakeRef(Input::fromURL(parsedURL, isFlake), getOr(parsedURL.query, "dir", "")),
+                            fragment);
+                    } else if (pathExists(flakeRoot + "/.pijul")) {
+                        auto base = std::string("pijul+file://") + flakeRoot;
+
+                        auto parsedURL = ParsedURL{
+                            .url = base, // FIXME
+                            .base = base,
+                            .scheme = "pijul+file",
+                            .authority = "",
+                            .path = flakeRoot,
+                            .query = decodeQuery(match[2]),
+                        };
+
+                        if (subdir != "") {
+                            if (parsedURL.query.count("dir"))
+                                throw Error("flake URL '%s' has an inconsistent 'dir' parameter", url);
+                            parsedURL.query.insert_or_assign("dir", subdir);
+                        }
+
                         return std::make_pair(
                             FlakeRef(Input::fromURL(parsedURL, isFlake), getOr(parsedURL.query, "dir", "")),
                             fragment);
-- 
2.42.0


D packages/nix-pijul/default.nix => packages/nix-pijul/default.nix +0 -11
@@ 1,11 0,0 @@
{
  nix ? nixUnstable,
  nixUnstable,
}:
nix.overrideAttrs (self: {
  patches =
    self.patches
    ++ [
      ./0011-Detect-Pijul-repositories-for-flake-paths.patch
    ];
})