ags: init at 2.2.1

This commit is contained in:
PerchunPak 2025-01-14 07:45:08 +01:00
parent f06ee37f84
commit 7bd40e30ed
No known key found for this signature in database
GPG Key ID: 313F67D1EAB770F9
6 changed files with 263 additions and 0 deletions

View File

@ -0,0 +1,39 @@
# Astal {#astal}
Astal is a collection of building blocks for creating custom desktop shells.
## Bundling {#astal-bundling}
Bundling Astal application is done using `ags` tool, you can use it like this:
```nix
ags.bundle {
pname = "hyprpanel";
version = "1.0.0";
src = fetchFromGitHub { ... };
# change your entry file (default is `app.ts`)
entry = "app.ts";
dependencies = [
# list here astal modules, that your package depends on
# `astal3`, `astal4` and `astal.io` are automatically included
astal.apps
astal.battery
astal.bluetooth
# you can also list here other runtime dependencies
hypridle
hyprpicker
hyprsunset
];
# GTK 4 support is opt-in
enableGtk4 = true;
meta = { ... };
}
```
You can also pass all other arguments that are supported by `stdenv.mkDerivation`.

View File

@ -53,6 +53,7 @@ Each supported language or software ecosystem has its own package set named `<la
```{=include=} sections
agda.section.md
android.section.md
astal.section.md
beam.section.md
bower.section.md
chicken.section.md

View File

@ -2349,6 +2349,12 @@
"using-predefined-android-package-compositions": [
"index.html#using-predefined-android-package-compositions"
],
"astal": [
"index.html#astal"
],
"astal-bundling": [
"index.html#astal-bundling"
],
"spawning-emulator-instances": [
"index.html#spawning-emulator-instances"
],

View File

@ -275,6 +275,13 @@
[v1.7.0](https://github.com/jtroo/kanata/releases/tag/v1.7.0)
for more information.
- `ags` was updated to v2, which is just a CLI for Astal now. Components are available as a different package set `astal.*`.
If you want to use v1, it is available as `ags_1` package.
See the release notes of
[v2.0.0](https://github.com/Aylur/ags/releases/tag/v2.0.0)
for more information.
- `nodePackages.expo-cli` has been removed, as it was deprecated by upstream. The suggested replacement is the `npx expo` command.
- DokuWiki with the Caddy webserver (`services.dokuwiki.webserver = "caddy"`) now sets up sites with Caddy's automatic HTTPS instead of HTTP-only.

View File

@ -0,0 +1,86 @@
{
lib,
ags,
astal,
dart-sass,
fzf,
gjs,
gnused,
gobject-introspection,
gtk3,
gtk4-layer-shell,
stdenvNoCC,
wrapGAppsHook3,
wrapGAppsHook4,
}:
{
entry ? "app.ts",
dependencies ? [ ],
enableGtk4 ? false,
...
}@attrs:
stdenvNoCC.mkDerivation (
finalAttrs:
attrs
// {
nativeBuildInputs = (attrs.nativeBuildInputs or [ ]) ++ [
(ags.override { extraPackages = dependencies; })
gnused
gobject-introspection
(if enableGtk4 then wrapGAppsHook4 else wrapGAppsHook3)
];
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
'';
}
)

View File

@ -0,0 +1,124 @@
{
lib,
astal,
blueprint-compiler,
buildGoModule,
callPackage,
dart-sass,
symlinkJoin,
fetchFromGitHub,
fetchpatch2,
gjs,
glib,
gobject-introspection,
gtk4-layer-shell,
installShellFiles,
nix-update-script,
nodejs,
stdenv,
wrapGAppsHook3,
extraPackages ? [ ],
}:
buildGoModule rec {
pname = "ags";
version = "2.2.1";
src = fetchFromGitHub {
owner = "Aylur";
repo = "ags";
tag = "v${version}";
hash = "sha256-snHhAgcH8hACWZFaAqHr5uXH412UrAuA603OK02MxN8=";
};
patches = [
# refactor for better nix support
(fetchpatch2 {
url = "https://github.com/Aylur/ags/commit/17df94c576d0023185770f901186db427f2ec0a2.diff?full_index=1";
hash = "sha256-tcoifkYmXjV+ZbeAFRHuk8cVmxWMrS64syvQMGGKAVA=";
})
];
vendorHash = "sha256-Pw6UNT5YkDVz4HcH7b5LfOg+K3ohrBGPGB9wYGAQ9F4=";
proxyVendor = true;
ldflags = [
"-s"
"-w"
"-X main.astalGjs=${astal.gjs}/share/astal/gjs"
"-X main.gtk4LayerShell=${gtk4-layer-shell}/lib/libgtk4-layer-shell.so"
];
nativeBuildInputs = [
wrapGAppsHook3
gobject-introspection
installShellFiles
];
buildInputs = extraPackages ++ [
glib
astal.io
astal.astal3
astal.astal4
gobject-introspection # needed for type generation
];
preFixup =
let
# git files are usually in `dev` output.
# `propagatedBuildInputs` are also available in the gjs runtime
# so we also want to generate types for these.
depsOf = pkg: [ (pkg.dev or pkg) ] ++ (map depsOf (pkg.propagatedBuildInputs or [ ]));
girDirs = symlinkJoin {
name = "gir-dirs";
paths = lib.flatten (map depsOf buildInputs);
};
in
''
gappsWrapperArgs+=(
--prefix EXTRA_GIR_DIRS : "${girDirs}/share/gir-1.0"
--prefix PATH : "${
lib.makeBinPath (
[
gjs
nodejs
dart-sass
blueprint-compiler
astal.io
]
++ extraPackages
)
}"
)
'';
postInstall =
lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform)
# bash
''
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 widget system";
homepage = "https://github.com/Aylur/ags";
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;
};
}