From e0567562465db738ce2f94274b556c95ed1fe160 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 22 Mar 2024 23:31:37 -0400 Subject: [PATCH] feat(astal): add basic working config --- modules/ags/astal/js/utils.js | 47 ++++++ modules/ags/astal/package-lock.json | 237 ++++++++++++++++++++++++++++ modules/ags/astal/package.json | 5 + modules/ags/astal/scss/wim.scss | 10 ++ modules/ags/astal/tsconfig.json | 23 +++ modules/ags/astal/wim.ts | 20 +++ modules/ags/default.nix | 25 +-- 7 files changed, 357 insertions(+), 10 deletions(-) create mode 100644 modules/ags/astal/js/utils.js create mode 100644 modules/ags/astal/package-lock.json create mode 100644 modules/ags/astal/package.json create mode 100644 modules/ags/astal/scss/wim.scss create mode 100644 modules/ags/astal/tsconfig.json create mode 100644 modules/ags/astal/wim.ts diff --git a/modules/ags/astal/js/utils.js b/modules/ags/astal/js/utils.js new file mode 100644 index 0000000..f7cce39 --- /dev/null +++ b/modules/ags/astal/js/utils.js @@ -0,0 +1,47 @@ +const { execAsync, monitorFile } = Utils; + + +/** @param {string} host */ +const watchAndCompileSass = (host) => { + const reloadCss = () => { + const scss = `${App.configDir}/scss/${host}.scss`; + const css = `/tmp/astal-${host}/style.css`; + + execAsync(`sass ${scss} ${css}`).then(() => { + App.resetCss(); + App.applyCss(css); + }).catch(print); + }; + + monitorFile( + `${App.configDir}/scss`, + reloadCss, + ); + reloadCss(); +}; + +/** @param {string} host */ +export const transpileTypeScript = async(host) => { + const outPath = `/tmp/astal-${host}/index.js`; + + await execAsync([ + 'bash', '-c', + // Create the dir if it doesn't exist + `mkdir -p /tmp/astal-${host}; ` + + + `bun build ${App.configDir}/${host}.ts ` + + '--external resource:///* ' + + '--external gi://* ' + + '--external cairo ' + + '--external */fzf.es.js ' + + + // Since bun wants to right in cwd, we just redirect stdin instead + `> ${outPath}`, + ]).catch(print); + + if (host !== 'greeter') { + watchAndCompileSass(host); + } + + return await import(`file://${outPath}`); +}; diff --git a/modules/ags/astal/package-lock.json b/modules/ags/astal/package-lock.json new file mode 100644 index 0000000..64f13b6 --- /dev/null +++ b/modules/ags/astal/package-lock.json @@ -0,0 +1,237 @@ +{ + "name": "astal", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "@girs/adw-1": "^1.4.3-3.2.9" + } + }, + "node_modules/@girs/adw-1": { + "version": "1.4.3-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/adw-1/-/adw-1-1.4.3-3.2.9.tgz", + "integrity": "sha512-FJPtFRLJHXHZl5WEPjXmyKXaoIgBWurZMroSxNxpRGFVlbxx7wq4Q1k1iKKVxcKbe69z66GQsHV2BgaeQK0aXg==", + "dev": true, + "dependencies": { + "@girs/cairo-1.0": "^1.0.0-3.2.9", + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gdk-4.0": "^4.0.0-3.2.9", + "@girs/gdkpixbuf-2.0": "^2.0.0-3.2.9", + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gmodule-2.0": "^2.0.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9", + "@girs/graphene-1.0": "^1.0.0-3.2.9", + "@girs/gsk-4.0": "^4.0.0-3.2.9", + "@girs/gtk-4.0": "^4.12.5-3.2.9", + "@girs/harfbuzz-0.0": "^8.2.1-3.2.9", + "@girs/pango-1.0": "^1.51.0-3.2.9", + "@girs/pangocairo-1.0": "^1.0.0-3.2.9" + } + }, + "node_modules/@girs/cairo-1.0": { + "version": "1.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/cairo-1.0/-/cairo-1.0-1.0.0-3.2.9.tgz", + "integrity": "sha512-yeBoeyniCKU3IcgpoKUywlviBx2kEVeYjglFw4v5eGGvaBugPWvlShqePxfNmfh2A4cjFzzdLXRN6brQEHgQEA==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/freetype2-2.0": { + "version": "2.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/freetype2-2.0/-/freetype2-2.0-2.0.0-3.2.9.tgz", + "integrity": "sha512-Og9CTSl2QYnuCtX2L6rYa9WVUetYbaD1Y7BwEe3kOSG2OkDB+hunnF82x1Ctg1iKRRBXgWxadKb28bm2wKx/Jw==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/gdk-4.0": { + "version": "4.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gdk-4.0/-/gdk-4.0-4.0.0-3.2.9.tgz", + "integrity": "sha512-86+32kDXaSqzicqMCx35O8ZkCrG5Qyyozaq1NQdWhBNUopGNiTLtVkf90aIP0y8ZccIeJKidCWEO3IYiRmmHkg==", + "dev": true, + "dependencies": { + "@girs/cairo-1.0": "^1.0.0-3.2.9", + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gdkpixbuf-2.0": "^2.0.0-3.2.9", + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gmodule-2.0": "^2.0.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9", + "@girs/harfbuzz-0.0": "^8.2.1-3.2.9", + "@girs/pango-1.0": "^1.51.0-3.2.9", + "@girs/pangocairo-1.0": "^1.0.0-3.2.9" + } + }, + "node_modules/@girs/gdkpixbuf-2.0": { + "version": "2.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gdkpixbuf-2.0/-/gdkpixbuf-2.0-2.0.0-3.2.9.tgz", + "integrity": "sha512-7guULwcaulcOvqvAB8pd6Xr9B2YmK1sQK6CYm5bHZQw9N18LnZkm9ATOAXjXLieaUSeERA6LnBPmtkLUZdeTzA==", + "dev": true, + "dependencies": { + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gmodule-2.0": "^2.0.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/gio-2.0": { + "version": "2.78.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gio-2.0/-/gio-2.0-2.78.0-3.2.9.tgz", + "integrity": "sha512-A3F1AkBPF8Up6bSfH9zbAUsQqv4dB0jvfUIo5b+SJs6Mt9FhpqNEUMyqeCFTDKDA9n2sK6JxAJviwsW9dxViJA==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/gjs": { + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gjs/-/gjs-3.2.9.tgz", + "integrity": "sha512-dJfCNdtt4OLRywlhKOc+h27l5KoOiDhbhkuuG/WaV/jn9KaQ1BMAyVWdBEZu6WzPJlsiWYujis0fe5ZJnrgoDA==", + "dev": true, + "dependencies": { + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/glib-2.0": { + "version": "2.78.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/glib-2.0/-/glib-2.0-2.78.0-3.2.9.tgz", + "integrity": "sha512-wcbnSojav6jc4//PYsAJPwXizFlz35/F+AHyFbvutOSdNz4xzzUUZqUhhH2lmoyR8WDvkVWBcQitCmYmPNe6Xg==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/gmodule-2.0": { + "version": "2.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gmodule-2.0/-/gmodule-2.0-2.0.0-3.2.9.tgz", + "integrity": "sha512-10JS6N7VkPxcom5I3hzD65NmZzQ63ZFmN+2KXZPwTDU6K2A2QrxZB2/3Q3j6KKNc+e/d9GhStL9ISUPLErHoNg==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/gobject-2.0": { + "version": "2.78.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gobject-2.0/-/gobject-2.0-2.78.0-3.2.9.tgz", + "integrity": "sha512-zszoqx7/z7KseQnc7WUXz1jgs3oYskT748cMKLQ7n4pRtL6klrTzlPbM42Szs+Uk6wOKJ+o+MMdcpb8znflDBg==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/graphene-1.0": { + "version": "1.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/graphene-1.0/-/graphene-1.0-1.0.0-3.2.9.tgz", + "integrity": "sha512-2iTdpt7XTJAH/K5GiKoF2r0BHe1JghpV+rh81WYtFqM/r9CLs5GipESuraVQvZeK2vyrZcGRjVmoDoiKiA3BlQ==", + "dev": true, + "dependencies": { + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/gsk-4.0": { + "version": "4.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gsk-4.0/-/gsk-4.0-4.0.0-3.2.9.tgz", + "integrity": "sha512-LtGbMKBVYPburnI1JGt2d3uKzHgk4A2QtO4n/kP0T99Rmnxr+D2xwR+VdqcdgkLXoTzdlvodfK1b7W/eILB7CQ==", + "dev": true, + "dependencies": { + "@girs/cairo-1.0": "^1.0.0-3.2.9", + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gdk-4.0": "^4.0.0-3.2.9", + "@girs/gdkpixbuf-2.0": "^2.0.0-3.2.9", + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gmodule-2.0": "^2.0.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9", + "@girs/graphene-1.0": "^1.0.0-3.2.9", + "@girs/harfbuzz-0.0": "^8.2.1-3.2.9", + "@girs/pango-1.0": "^1.51.0-3.2.9", + "@girs/pangocairo-1.0": "^1.0.0-3.2.9" + } + }, + "node_modules/@girs/gtk-4.0": { + "version": "4.12.5-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/gtk-4.0/-/gtk-4.0-4.12.5-3.2.9.tgz", + "integrity": "sha512-TweLlhryVS8DnDQouLdJtGv3AeJ9Dv/nKFatPSDlcwUFYCSDa9+R5gA5L7GNh3NobPIa6ZMAT4oAv2fJS7zYFw==", + "dev": true, + "dependencies": { + "@girs/cairo-1.0": "^1.0.0-3.2.9", + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gdk-4.0": "^4.0.0-3.2.9", + "@girs/gdkpixbuf-2.0": "^2.0.0-3.2.9", + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gmodule-2.0": "^2.0.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9", + "@girs/graphene-1.0": "^1.0.0-3.2.9", + "@girs/gsk-4.0": "^4.0.0-3.2.9", + "@girs/harfbuzz-0.0": "^8.2.1-3.2.9", + "@girs/pango-1.0": "^1.51.0-3.2.9", + "@girs/pangocairo-1.0": "^1.0.0-3.2.9" + } + }, + "node_modules/@girs/harfbuzz-0.0": { + "version": "8.2.1-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/harfbuzz-0.0/-/harfbuzz-0.0-8.2.1-3.2.9.tgz", + "integrity": "sha512-5o4Ow44ndt9Jnyp5vw6tWYSFESY/inH/3nNoWk1bWpG5TFxOwvW05RiSpdKXb4nTXaDWPBXLZF4Its9Q/GrW2w==", + "dev": true, + "dependencies": { + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9" + } + }, + "node_modules/@girs/pango-1.0": { + "version": "1.51.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/pango-1.0/-/pango-1.0-1.51.0-3.2.9.tgz", + "integrity": "sha512-dWIvPJoFnpgWQcflTyGhXN5TmlmW0OvTG6kjBFwVJLwT2H6vugUKk9665MvEQDywaeGZzdfrJqQo/oFplhVSBg==", + "dev": true, + "dependencies": { + "@girs/cairo-1.0": "^1.0.0-3.2.9", + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9", + "@girs/harfbuzz-0.0": "^8.2.1-3.2.9" + } + }, + "node_modules/@girs/pangocairo-1.0": { + "version": "1.0.0-3.2.9", + "resolved": "https://registry.npmjs.org/@girs/pangocairo-1.0/-/pangocairo-1.0-1.0.0-3.2.9.tgz", + "integrity": "sha512-9tpiYEwdx9829p0oQFrC5Y38USGeap2Y+yNeD8Klf1Pb9pGC/lVjAjrqmGC/nSAyLHz3SlK1kTDP1fBsqoCEng==", + "dev": true, + "dependencies": { + "@girs/cairo-1.0": "^1.0.0-3.2.9", + "@girs/freetype2-2.0": "^2.0.0-3.2.9", + "@girs/gio-2.0": "^2.78.0-3.2.9", + "@girs/gjs": "^3.2.9", + "@girs/glib-2.0": "^2.78.0-3.2.9", + "@girs/gobject-2.0": "^2.78.0-3.2.9", + "@girs/harfbuzz-0.0": "^8.2.1-3.2.9", + "@girs/pango-1.0": "^1.51.0-3.2.9" + } + } + } +} diff --git a/modules/ags/astal/package.json b/modules/ags/astal/package.json new file mode 100644 index 0000000..63f59fb --- /dev/null +++ b/modules/ags/astal/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "@girs/adw-1": "^1.4.3-3.2.9" + } +} diff --git a/modules/ags/astal/scss/wim.scss b/modules/ags/astal/scss/wim.scss new file mode 100644 index 0000000..1a14d46 --- /dev/null +++ b/modules/ags/astal/scss/wim.scss @@ -0,0 +1,10 @@ +window { + all: unset; +} + + +.base { + background-color: #{"@window_bg_color"}; + border: 1px solid #{"@accent_bg_color"}; + padding: 5px; +} diff --git a/modules/ags/astal/tsconfig.json b/modules/ags/astal/tsconfig.json new file mode 100644 index 0000000..0feb1cf --- /dev/null +++ b/modules/ags/astal/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "lib": [ + "ES2022" + ], + "allowJs": true, + "checkJs": true, + "strict": true, + "noImplicitAny": false, + "baseUrl": ".", + "paths": { + "gi://Adw": ["./node_modules/@girs/adw-1/adw-1.d.ts"], + "gi://Adw?version=1": ["./node_modules/@girs/adw-1/adw-1.d.ts"] + }, + "typeRoots": [ + "./types", + "./node_modules" + ], + "skipLibCheck": true + }, +} diff --git a/modules/ags/astal/wim.ts b/modules/ags/astal/wim.ts new file mode 100644 index 0000000..e6c546a --- /dev/null +++ b/modules/ags/astal/wim.ts @@ -0,0 +1,20 @@ +import Adw from 'gi://Adw'; + + +App.config({ + windows: () => [ + Widget.Window({ + name: 'test', + + child: Widget.Box({ + setup: (self) => { + self.toggleCssClass('base'); + }, + + child: new Adw.SplitButton({ + label: 'test', + }), + }), + }), + ], +}); diff --git a/modules/ags/default.nix b/modules/ags/default.nix index 6183fa7..215016d 100644 --- a/modules/ags/default.nix +++ b/modules/ags/default.nix @@ -28,10 +28,21 @@ in { inherit (lib) optionals; astalTypes = config.home.file.".local/share/io.Aylur.Astal/types"; + astalConfigDir = ".nix/modules/ags/astal"; # https://github.com/Aylur/ags/blob/e1f2d311ceb496a69ef6daa6aebb46ce511b2f22/nix/hm-module.nix#L69 agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types"; agsConfigDir = ".nix/modules/ags/config"; + + configJs = + /* + javascript + */ + '' + import { transpileTypeScript } from './js/utils.js'; + + export default (await transpileTypeScript('${hostName}')).default; + ''; in { # Experimental Gtk4 ags programs.astal = { @@ -46,19 +57,13 @@ in { home = { file = { - ".config/astal/types".source = astalTypes.source; + ".config/astal".source = symlink /home/${mainUser}/.nix/modules/ags/astal; + "${astalConfigDir}/types".source = astalTypes.source; + "${astalConfigDir}/config.js".text = configJs; ".config/ags".source = symlink /home/${mainUser}/.nix/modules/ags/config; "${agsConfigDir}/types".source = agsTypes.source; - "${agsConfigDir}/config.js".text = - /* - javascript - */ - '' - import { transpileTypeScript } from './js/utils.js'; - - export default (await transpileTypeScript('${hostName}')).default; - ''; + "${agsConfigDir}/config.js".text = configJs; } // (import ./icons.nix {inherit pkgs agsConfigDir;});