Skip to content

Commit

Permalink
gix(build): app emplacement
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Jan 21, 2025
1 parent d38387b commit 5012afa
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 60 deletions.
56 changes: 28 additions & 28 deletions apps/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ let

applyInputPatches = name: attrs:
{
frappe =
frappe = let
workdirsrc = applyPatches {
name = "frappe-source-1";
inherit (attrs) src;
# this patch is needs to be present in all source trees,
# such as the next one used for the assets below
patches = [
# This mariadb has passwordless root access
# for the current user
./sources/frappe-uds-current-user-v15.patch
# ./sources/frappe-uds-current-user-develop.patch
];
};
deploysrc = applyPatches {
name = "frappe-source-2";
src = workdirsrc;
patches = [
# make the relative path to the generator script absolute
# but reference the already patched version to work with uds
(substituteAll {
src = ./sources/frappe-website-generator.patch;
frappe = workdirsrc;
})
];
};
in
attrs
// {
src = let
stage_1 = applyPatches {
name = "frappe-source-1";
inherit (attrs) src;
# this patch is needs to be present in all source trees,
# such as the next one used for the assets below
patches = [
# This mariadb has passwordless root access
# for the current user
./sources/frappe-uds-current-user-v15.patch
# ./sources/frappe-uds-current-user-develop.patch
];
};
stage_2 = applyPatches {
name = "frappe-source-2";
src = stage_1;
patches = [
# make the relative path to the generator script absolute
# but reference the already patched version to work with uds
(substituteAll {
src = ./sources/frappe-website-generator.patch;
frappe = stage_1;
})
];
};
in
stage_2;
src = deploysrc;
passthru = (attrs.passthru or {}) // {inherit workdirsrc;};
};
}
.${name}
Expand Down
18 changes: 10 additions & 8 deletions apps/sources/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ use_max_tag = true
github = "frappe/frappe"

[frappe.passthru]
[frappe.passthru.clone]
since = "version-14"
upstream = """
URL: https://github.com/frappe/frappe
Pull: +refs/heads/develop:refs/remotes/upstream/develop
Pull: +refs/heads/version-15:refs/remotes/upstream/version-15
Pull: +refs/heads/version-15-hotfix:refs/remotes/upstream/version-15-hotfix
Pull: +refs/tags/v15.*:refs/remotes/upstream/tags/v15.*
"""

[frappe.passthru.clone.upstream]
fetch = [
"+refs/heads/develop:refs/remotes/upstream/develop",
"+refs/heads/version-15:refs/remotes/upstream/version-15",
"+refs/heads/version-15-hotfix:refs/remotes/upstream/version-15-hotfix",
"+refs/tags/v15.*:refs/remotes/upstream/tags/v15.*",
]

url = "https://github.com/frappe/frappe"
[erpnext]
source = "github"
use_max_tag = true
Expand Down
2 changes: 1 addition & 1 deletion apps/sources/frappe.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
narHash = "sha256-NRagXPZMIPLipe2gus79SYvxDRQx9SMmaLnBvxKnXv0=";
rev = "3eda272bd61b1e73b74d30b1704d885a39c75d0c";
};
passthru = builtins.fromJSON ''{"since": "version-14", "upstream": "URL: https://github.com/frappe/frappe\nPull: +refs/heads/develop:refs/remotes/upstream/develop\nPull: +refs/heads/version-15:refs/remotes/upstream/version-15\nPull: +refs/heads/version-15-hotfix:refs/remotes/upstream/version-15-hotfix\nPull: +refs/tags/v15.*:refs/remotes/upstream/tags/v15.*\n"}'';
passthru = builtins.fromJSON ''{"clone": {"since": "version-14", "upstream": {"fetch": ["+refs/heads/develop:refs/remotes/upstream/develop", "+refs/heads/version-15:refs/remotes/upstream/version-15", "+refs/heads/version-15-hotfix:refs/remotes/upstream/version-15-hotfix", "+refs/tags/v15.*:refs/remotes/upstream/tags/v15.*"], "url": "https://github.com/frappe/frappe"}}}'';
}
49 changes: 26 additions & 23 deletions src/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -205,30 +205,33 @@ in {
};
emplace-apps = {
text = let
clone = app:
# bash
''
if [[ ! -d "$PRJ_ROOT/apps/${app.pname}" ]]; then
git clone --config "diff.fsjd.command=fsjd --git" \
--origin upstream ${
lib.optionalString (app ? since) ''--shallow-exclude="'' + app.since + ''"''
} "${app.pin.src.gitRepoUrl}" \
"$PRJ_ROOT/apps/${app.pname}"
(
cd "$PRJ_ROOT/apps/${app.pname}";
mkdir .git/remotes;
${
lib.optionalString (app ? upstream) ''echo "${app.upstream}" > .git/remotes/upstream;''
}
git switch -c custom;
(diff -ura $PRJ_ROOT/apps/${app.pname} ${app.src} | patch --strip 4) || true;
git add . && git commit -m 'FRAPPIX START' --no-verify --allow-empty --no-gpg-sign
yarn --silent || true
)
fi
'';
doClone = app: let
inherit (app) clone;
maybeShallow = lib.optionalString (clone ? since) "--shallow-exclude=${clone.since}";
in
# bash
''
if [[ ! -d "$PRJ_ROOT/apps/${app.pname}" ]]; then
git clone --config "diff.fsjd.command=fsjd --git" \
--origin upstream \
--branch ${app.src.version} ${maybeShallow} \
"${clone.upstream.url}" \
"$PRJ_ROOT/apps/${app.pname}"
pushd "$PRJ_ROOT/apps/${app.pname}"
git config set --local --comment 'frappix setup' remote.upstream.url '${clone.upstream.url}'
${lib.concatStringsSep "\n" (map (
i: "git config --add --local --comment 'frappix setup' remote.upstream.fetch '${i}'"
)
clone.upstream.fetch)}
git switch -c fork;
(diff -ura $PRJ_ROOT/apps/${app.pname} ${app.workdirsrc} | patch --strip 4) || true;
git add . && git commit -m 'FRAPPIX START' --no-verify --allow-empty --no-gpg-sign
yarn --silent || true
popd
fi
'';
in ''
${lib.concatMapStrings clone (lib.filter (a: a ? pin) cfg.apps)}
${lib.concatMapStrings doClone (lib.filter (a: a ? clone) cfg.apps)}
'';
deps = ["emplace-pyenv" "ensure-env-vars"];
};
Expand Down

0 comments on commit 5012afa

Please sign in to comment.