mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-18 19:10:45 +08:00
Split out package function into external file
Refactor the radicle-desktop build function in the flake by splitting it into an external file. Use file-based scoping to prevent access to global symbols within the build function.
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
watch_file flake.lock rust-toolchain
|
||||
watch_file rust-toolchain nix/*
|
||||
|
||||
use flake
|
||||
|
||||
@@ -55,108 +55,13 @@
|
||||
hash = "sha256-YoOnZ5uVukzi/6bLi22Y8U5TpplPzB7ji42l+/ys5xI=";
|
||||
};
|
||||
|
||||
radicle-desktop = pkgs.callPackage (
|
||||
{
|
||||
lib,
|
||||
importNpmLock,
|
||||
rust-bin,
|
||||
makeRustPlatform,
|
||||
cargo-tauri,
|
||||
nodejs,
|
||||
pkg-config,
|
||||
wrapGAppsHook4,
|
||||
glib,
|
||||
gtk3,
|
||||
libsoup_3,
|
||||
openssl,
|
||||
webkitgtk_4_1,
|
||||
git,
|
||||
openssh,
|
||||
}: let
|
||||
rTc = rust-bin.fromRustupToolchainFile ./rust-toolchain;
|
||||
rustPlatform = makeRustPlatform {
|
||||
cargo = rTc;
|
||||
rustc = rTc;
|
||||
};
|
||||
in rustPlatform.buildRustPackage rec {
|
||||
pname = "radicle-desktop";
|
||||
inherit (with builtins; (fromJSON (readFile ./package.json))) version;
|
||||
|
||||
src = ./.;
|
||||
|
||||
cargoDeps = rustPlatform.importCargoLock {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"radicle-0.14.0" = "sha256-F7pJ+yLhlRXg03A+pNXwsqNSOG3qJs6bEO9YUUXs4f0=";
|
||||
};
|
||||
};
|
||||
|
||||
npmDeps = importNpmLock {
|
||||
inherit version;
|
||||
pname = pname + "-npm-deps";
|
||||
npmRoot = ./.;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo-tauri.hook
|
||||
nodejs
|
||||
importNpmLock.npmConfigHook
|
||||
pkg-config
|
||||
wrapGAppsHook4
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
glib gtk3 libsoup_3 openssl webkitgtk_4_1
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs scripts/copy-katex-assets scripts/check-js scripts/check-rs
|
||||
mkdir -p public/twemoji
|
||||
cp -t public/twemoji -r -- ${self.packages.${system}.twemoji-assets}/assets/svg/*
|
||||
: >scripts/install-twemoji-assets
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
nativeCheckInputs = [ git openssh ];
|
||||
|
||||
env = {
|
||||
HW_RELEASE = "nix-" + (heartwood.shortRev or "unknown-ref");
|
||||
PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1;
|
||||
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
|
||||
RUST_SRC_PATH = "${rTc}/lib/rustlib/src/rust/library";
|
||||
} // (
|
||||
if self ? rev || self ? dirtyRev
|
||||
then {
|
||||
GIT_HEAD = self.rev or self.dirtyRev;
|
||||
}
|
||||
else {}
|
||||
);
|
||||
|
||||
preCheck = ''
|
||||
export RAD_HOME="$PWD/_rad-home"
|
||||
export RAD_PASSPHRASE=""
|
||||
rad auth --alias test
|
||||
bins="tests/tmp/bin/heartwood/$HW_RELEASE"
|
||||
mkdir -p "$bins"
|
||||
cp -t "$bins" -- ${heartwood.packages.${system}.radicle}/bin/*
|
||||
printf "$HW_RELEASE" >tests/support/heartwood-release
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
npm run build:http
|
||||
npm run test:unit
|
||||
scripts/check-js
|
||||
scripts/check-rs
|
||||
'';
|
||||
|
||||
passthru.env = env;
|
||||
meta = {
|
||||
description = "Radicle Desktop App";
|
||||
license = lib.licenses.gpl3;
|
||||
maintainers = [ ];
|
||||
};
|
||||
}) {};
|
||||
radicle-desktop = pkgs.callPackage ./nix/radicle-desktop.nix {
|
||||
inherit heartwood;
|
||||
inherit (self.packages.${system}) twemoji-assets;
|
||||
}
|
||||
// (if self ? rev || self ? dirtyRev then {
|
||||
GIT_HEAD = if self ? rev then self.rev else self.dirtyRev;
|
||||
} else {});
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
{
|
||||
lib,
|
||||
importNpmLock,
|
||||
rust-bin,
|
||||
makeRustPlatform,
|
||||
cargo-tauri,
|
||||
nodejs,
|
||||
pkg-config,
|
||||
wrapGAppsHook4,
|
||||
glib,
|
||||
gtk3,
|
||||
libsoup_3,
|
||||
openssl,
|
||||
webkitgtk_4_1,
|
||||
git,
|
||||
openssh,
|
||||
system,
|
||||
playwright-driver,
|
||||
heartwood,
|
||||
twemoji-assets,
|
||||
GIT_HEAD ? null,
|
||||
}:
|
||||
let
|
||||
rTc = rust-bin.fromRustupToolchainFile ./../rust-toolchain;
|
||||
rustPlatform = makeRustPlatform {
|
||||
cargo = rTc;
|
||||
rustc = rTc;
|
||||
};
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "radicle-desktop";
|
||||
inherit (with builtins; (fromJSON (readFile ./../package.json))) version;
|
||||
|
||||
src = ./..;
|
||||
|
||||
cargoDeps = rustPlatform.importCargoLock {
|
||||
lockFile = ./../Cargo.lock;
|
||||
outputHashes = {
|
||||
"radicle-0.14.0" = "sha256-F7pJ+yLhlRXg03A+pNXwsqNSOG3qJs6bEO9YUUXs4f0=";
|
||||
};
|
||||
};
|
||||
|
||||
npmDeps = importNpmLock {
|
||||
inherit version;
|
||||
pname = pname + "-npm-deps";
|
||||
npmRoot = ./..;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo-tauri.hook
|
||||
nodejs
|
||||
importNpmLock.npmConfigHook
|
||||
pkg-config
|
||||
wrapGAppsHook4
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
glib
|
||||
gtk3
|
||||
libsoup_3
|
||||
openssl
|
||||
webkitgtk_4_1
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs scripts/copy-katex-assets scripts/check-js scripts/check-rs
|
||||
mkdir -p public/twemoji
|
||||
cp -t public/twemoji -r -- ${twemoji-assets}/assets/svg/*
|
||||
: >scripts/install-twemoji-assets
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
nativeCheckInputs = [
|
||||
git
|
||||
openssh
|
||||
];
|
||||
|
||||
env =
|
||||
{
|
||||
HW_RELEASE = "nix-" + (heartwood.shortRev or "unknown-ref");
|
||||
PLAYWRIGHT_BROWSERS_PATH = playwright-driver.browsers;
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1;
|
||||
PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
|
||||
RUST_SRC_PATH = "${rTc}/lib/rustlib/src/rust/library";
|
||||
}
|
||||
// (lib.optionalAttrs (GIT_HEAD != null) {
|
||||
inherit GIT_HEAD;
|
||||
});
|
||||
|
||||
preCheck = ''
|
||||
export RAD_HOME="$PWD/_rad-home"
|
||||
export RAD_PASSPHRASE=""
|
||||
rad auth --alias test
|
||||
bins="tests/tmp/bin/heartwood/$HW_RELEASE"
|
||||
mkdir -p "$bins"
|
||||
cp -t "$bins" -- ${heartwood.packages.${system}.radicle}/bin/*
|
||||
printf "$HW_RELEASE" >tests/support/heartwood-release
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
npm run build:http
|
||||
npm run test:unit
|
||||
scripts/check-js
|
||||
scripts/check-rs
|
||||
'';
|
||||
|
||||
passthru.env = env;
|
||||
meta = {
|
||||
description = "Radicle Desktop App";
|
||||
license = lib.licenses.gpl3;
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user