217 lines
4.7 KiB
Nix
217 lines
4.7 KiB
Nix
{
|
|
inputs',
|
|
lib,
|
|
stdenv,
|
|
stdenvNoCC,
|
|
moreutils,
|
|
pnpm_10,
|
|
buildNpmPackage,
|
|
wrapGAppsHook4,
|
|
gobject-introspection,
|
|
glib,
|
|
gjs,
|
|
libadwaita,
|
|
pywal16,
|
|
dart-sass,
|
|
psmisc,
|
|
socat,
|
|
}:
|
|
let
|
|
packageJSON = lib.importJSON ../package.json;
|
|
pname = packageJSON.name;
|
|
version = packageJSON.version;
|
|
|
|
# Cleaned sources from this repository
|
|
src = lib.fileset.toSource {
|
|
root = ../.;
|
|
fileset = lib.fileset.difference ../. (
|
|
lib.fileset.unions [
|
|
../flake.nix
|
|
../flake.lock
|
|
../result
|
|
../build
|
|
./.
|
|
]
|
|
);
|
|
};
|
|
|
|
# Derivation building just the gresources file
|
|
colorshellResources = stdenv.mkDerivation {
|
|
pname = "${pname}-resources.gresource";
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
buildInputs = [
|
|
glib
|
|
];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
glib-compile-resources resources.gresource.xml \
|
|
--sourcedir ./resources \
|
|
--target resources.gresource
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
cp resources.gresource $out
|
|
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
# Cleaned sources, with FHS paths patched out.
|
|
colorshellSrc = stdenvNoCC.mkDerivation {
|
|
pname = "${pname}-src";
|
|
inherit version;
|
|
|
|
inherit src;
|
|
|
|
postPatch = ''
|
|
# Copy the ags JS lib from the Nix store into the source tree so pnpm can
|
|
# treat it as a local file: dependency (no /nix/store path inside pnpm).
|
|
cp -R ${inputs'.ags.packages.ags.jsPackage} ags-js-lib
|
|
|
|
# Point the devDependency at the local copy instead of the FHS path.
|
|
substituteInPlace package.json \
|
|
--replace-fail "file:/usr/share/ags/js" "file:./ags-js-lib"
|
|
|
|
# Update the lockfile to reference the local copy as well.
|
|
# We need to keep specifiers in sync with package.json to satisfy
|
|
# pnpm's frozen-lockfile check.
|
|
substituteInPlace pnpm-lock.yaml \
|
|
--replace-fail "file:/usr/share/ags/js" "file:./ags-js-lib" \
|
|
--replace-fail "../../../../usr/share/ags/js" "./ags-js-lib"
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir $out
|
|
cp -rp * $out
|
|
'';
|
|
};
|
|
in
|
|
buildNpmPackage (finalAttrs: {
|
|
inherit pname version;
|
|
|
|
src = colorshellSrc;
|
|
sourceRoot = "${finalAttrs.src.name}";
|
|
|
|
npmConfigHook = pnpm_10.configHook;
|
|
npmDeps = finalAttrs.pnpmDeps;
|
|
pnpmDeps = pnpm_10.fetchDeps {
|
|
inherit (finalAttrs)
|
|
pname
|
|
version
|
|
src
|
|
sourceRoot
|
|
;
|
|
|
|
fetcherVersion = 2;
|
|
# Hash updated after local pnpmDeps build
|
|
hash = "sha256-m/aPNvv26r0DUvRUR4TL2GwwAHKvEIkc8Nvlm/jpnPc=";
|
|
|
|
# fetcher version 2 fails if there are no *-exec files in the output
|
|
preFixup = ''
|
|
touch $out/.dummy-exec
|
|
'';
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
wrapGAppsHook4
|
|
gobject-introspection
|
|
inputs'.ags.packages.default
|
|
moreutils
|
|
];
|
|
|
|
buildInputs = [
|
|
glib
|
|
gjs
|
|
libadwaita
|
|
inputs'.astal.packages.astal4
|
|
inputs'.astal.packages.apps
|
|
inputs'.astal.packages.auth
|
|
inputs'.astal.packages.battery
|
|
inputs'.astal.packages.bluetooth
|
|
inputs'.astal.packages.hyprland
|
|
inputs'.astal.packages.io
|
|
inputs'.astal.packages.mpris
|
|
inputs'.astal.packages.network
|
|
inputs'.astal.packages.notifd
|
|
inputs'.astal.packages.tray
|
|
inputs'.astal.packages.wireplumber
|
|
];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
# Allow incremental or repeated builds: don't fail if ./build already exists
|
|
mkdir -p build
|
|
outPath=./build/${packageJSON.name}
|
|
ags bundle ./src/app.ts $outPath \
|
|
--gtk 4 \
|
|
--root ./src \
|
|
--define "DEVEL=false" \
|
|
--define "COLORSHELL_VERSION='${finalAttrs.version}'" \
|
|
--define "GRESOURCES_FILE='${colorshellResources}'"
|
|
|
|
# add socket-communication support on executable
|
|
{
|
|
head -n1 $outPath
|
|
sed '1{/^#!.*$/d}' ${../scripts/socket.sh}
|
|
cat "$outPath" | sed '/^#!.*$/d'
|
|
} | sponge $outPath
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin
|
|
cp -rp build/${packageJSON.name} $out/bin/
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
preFixup = ''
|
|
gappsWrapperArgs+=(
|
|
--prefix PATH : ${
|
|
lib.makeBinPath [
|
|
# runtime executables
|
|
pywal16 # provides `wal` for colorshell's wallpaper module
|
|
dart-sass
|
|
glib
|
|
psmisc
|
|
socat
|
|
]
|
|
}
|
|
--prefix GI_TYPELIB_PATH : "${
|
|
lib.makeSearchPath "lib/girepository-1.0" (with inputs'.astal.packages; [
|
|
astal4
|
|
apps
|
|
auth
|
|
battery
|
|
bluetooth
|
|
hyprland
|
|
io
|
|
mpris
|
|
network
|
|
notifd
|
|
tray
|
|
wireplumber
|
|
])
|
|
}"
|
|
)
|
|
'';
|
|
|
|
passthru = {
|
|
resources = colorshellResources;
|
|
};
|
|
})
|
|
|
|
|