Skip to content

Commit

Permalink
ags: 1.8.2 -> 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PerchunPak committed Jan 13, 2025
1 parent bbc6850 commit 901b623
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 43 deletions.
89 changes: 89 additions & 0 deletions pkgs/by-name/ag/ags/bundle.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
lib,
ags,
astal,
dart-sass,
fzf,
gjs,
gnused,
gobject-introspection,
gtk3,
gtk4-layer-shell,
stdenvNoCC,
wrapGAppsHook,
}:
{
entry ? "app.ts",
dependencies ? [ ],
enableGtk4 ? false,
...
}@attrs:
stdenvNoCC.mkDerivation (
finalAttrs:
attrs
// {
nativeBuildInputs = (attrs.nativeBuildInputs or [ ]) ++ [
wrapGAppsHook
gobject-introspection
gnused
ags
];

buildInputs =
(attrs.buildInputs or [ ])
++ dependencies
++ [
gjs
astal.astal4
astal.astal3
astal.io
];

preFixup =
''
gappsWrapperArgs+=(
--prefix PATH : ${
lib.makeBinPath (
dependencies
++ [
dart-sass
fzf
gtk3
]
)
}
)
''
+ lib.optionalString enableGtk4 ''
gappsWrapperArgs+=(
--set LD_PRELOAD "${gtk4-layer-shell}/lib/libgtk4-layer-shell.so"
)
''
+ (attrs.preFixup or "");

installPhase =
let
outBin = "$out/bin/${finalAttrs.pname}";
in
# bash
''
runHook preInstall
mkdir -p "$out/bin" "$out/share"
cp -r ./* "$out/share"
ags bundle "${entry}" "${outBin}" -d "SRC='$out/share'"
chmod +x "${outBin}"
if ! head -n 1 "${outBin}" | grep -q "^#!"; then
sed -i '1i #!${gjs}/bin/gjs -m' "${outBin}"
fi
runHook postInstall
'';

meta = (attrs.meta or { }) // {
mainProgram = finalAttrs.pname;
};
}
)
113 changes: 70 additions & 43 deletions pkgs/by-name/ag/ags/package.nix
Original file line number Diff line number Diff line change
@@ -1,78 +1,105 @@
{
lib,
buildNpmPackage,
astal,
blueprint-compiler,
buildGoModule,
callPackage,
dart-sass,
fetchFromGitHub,
meson,
ninja,
pkg-config,
gobject-introspection,
gjs,
glib-networking,
gnome-bluetooth,
gtk-layer-shell,
libpulseaudio,
libsoup_3,
networkmanager,
upower,
typescript,
wrapGAppsHook3,
linux-pam,
glib,
gobject-introspection,
gtk4-layer-shell,
installShellFiles,
nix-update-script,
nodejs,
wrapGAppsHook3,
writers,

extraPackages ? [ ],
}:
let
datadirs =
writers.writeNu "datadirs"
# nu
''
$env.XDG_DATA_DIRS
| split row ":"
| filter { $"($in)/gir-1.0" | path exists }
| str join ":"
'';

buildNpmPackage rec {
bins = [
gjs
nodejs
dart-sass
blueprint-compiler
astal.io
];
in
buildGoModule rec {
pname = "ags";
version = "1.8.2";
version = "2.2.1";

src = fetchFromGitHub {
owner = "Aylur";
repo = "ags";
rev = "v${version}";
hash = "sha256-ebnkUaee/pnfmw1KmOZj+MP1g5wA+8BT/TPKmn4Dkwc=";
fetchSubmodules = true;
tag = "v${version}";
hash = "sha256-snHhAgcH8hACWZFaAqHr5uXH412UrAuA603OK02MxN8=";
};

npmDepsHash = "sha256-ucWdADdMqAdLXQYKGOXHNRNM9bhjKX4vkMcQ8q/GZ20=";
vendorHash = "sha256-Pw6UNT5YkDVz4HcH7b5LfOg+K3ohrBGPGB9wYGAQ9F4=";
proxyVendor = true;

mesonFlags = [ (lib.mesonBool "build_types" true) ];
ldflags = [
"-s"
"-w"
"-X main.astalGjs=${astal.gjs}/share/astal/gjs"
"-X main.gtk4LayerShell=${gtk4-layer-shell}/lib/libgtk4-layer-shell.so"
];

nativeBuildInputs = [
meson
ninja
pkg-config
gjs
gobject-introspection
typescript
wrapGAppsHook3
gobject-introspection
installShellFiles
];

# Most of the build inputs here are basically needed for their typelibs.
buildInputs = [
gjs
glib-networking
gnome-bluetooth
gtk-layer-shell
libpulseaudio
libsoup_3
linux-pam
networkmanager
upower
buildInputs = extraPackages ++ [
glib
astal.io
astal.astal3
astal.astal4
];

postPatch = ''
chmod u+x ./post_install.sh && patchShebangs ./post_install.sh
preFixup = ''
gappsWrapperArgs+=(
--prefix NIX_GI_DIRS : "$(${datadirs})"
--prefix PATH : "${lib.makeBinPath (bins ++ extraPackages)}"
)
'';

passthru.updateScript = nix-update-script { };
postInstall = ''
installShellCompletion \
--cmd ags \
--bash <($out/bin/ags completion bash) \
--fish <($out/bin/ags completion fish) \
--zsh <($out/bin/ags completion zsh)
'';

passthru = {
bundle = callPackage ./bundle.nix { };
updateScript = nix-update-script { };
};

meta = {
description = "Scaffolding CLI for Astal+TypeScript";
homepage = "https://github.com/Aylur/ags";
description = "EWW-inspired widget system as a GJS library";
changelog = "https://github.com/Aylur/ags/releases/tag/v${version}";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [
foo-dogsquared
johnrtitor
perchun
];
mainProgram = "ags";
platforms = lib.platforms.linux;
Expand Down

0 comments on commit 901b623

Please sign in to comment.