Compare commits

..

No commits in common. "62dc1214e9ada4e66dac215bb6635ec49e6a2417" and "aa9723303be1ebe2083eb975e070311b52372399" have entirely different histories.

12 changed files with 88 additions and 140 deletions

View file

@ -1,7 +1,6 @@
{ {
inputs ? {}, inputs ? {},
pkgs ? {}, pkgs ? {},
self ? {},
}: let }: let
lock = builtins.fromJSON (builtins.readFile ../flake.lock); lock = builtins.fromJSON (builtins.readFile ../flake.lock);
@ -10,12 +9,11 @@
sha256 = lock.nodes.nixpkgs.locked.narHash; sha256 = lock.nodes.nixpkgs.locked.narHash;
}}/lib"; }}/lib";
inherit (lib) concatStringsSep optionalAttrs stringToCharacters substring tail toUpper; inherit (lib) optionalAttrs;
mkVersion = src: "0.0.0+" + src.shortRev; mkVersion = src: "0.0.0+" + src.shortRev;
capitalise = str: (toUpper (substring 0 1 str) + (concatStringsSep "" (tail (stringToCharacters str))));
in in
{inherit lib mkVersion capitalise;} {inherit lib mkVersion;}
// (import ./inputs.nix lib lock) // (import ./inputs.nix lib lock)
// optionalAttrs (inputs != {}) (import ./flake-lib.nix inputs) // optionalAttrs (inputs != {}) (import ./flake-lib.nix inputs)
// optionalAttrs (pkgs != {}) (import ./pkgs.nix pkgs mkVersion capitalise self) // optionalAttrs (pkgs != {}) (import ./pkgs.nix pkgs mkVersion)

View file

@ -1,4 +1,4 @@
pkgs: mkVersion: capitalise: self: { pkgs: mkVersion: {
buildPlugin = pname: src: buildPlugin = pname: src:
pkgs.vimUtils.buildVimPlugin { pkgs.vimUtils.buildVimPlugin {
inherit pname src; inherit pname src;
@ -21,29 +21,4 @@ pkgs: mkVersion: capitalise: self: {
dontNpmBuild = true; dontNpmBuild = true;
}) {}; }) {};
in "${pkg}/lib/node_modules/${pkg.pname}/node_modules"; in "${pkg}/lib/node_modules/${pkg.pname}/node_modules";
buildNodeTypes = {
configPath,
packages,
pname,
}: let
inherit (pkgs.lib) concatMapStrings elemAt length map optionalString splitString toLower;
withGirNames =
map (package: {
inherit package;
girName =
if package.pname == "astal-wireplumber"
then "AstalWp-0.1"
else (concatMapStrings capitalise (splitString "-" package.pname)) + "-0.1";
})
packages;
in {
"${configPath}${optionalString (length packages == 1) "/${toLower (elemAt withGirNames 0).girName}"}".source =
pkgs.callPackage
./mk-types {
inherit (self.inputs) ts-for-gir-src;
inherit pname withGirNames;
};
};
} }

View file

@ -4,10 +4,10 @@ self: {
pkgs, pkgs,
... ...
}: let }: let
inherit (self.inputs) ags astal gtk-session-lock; inherit (self.inputs) ags astal gtk-session-lock ts-for-gir-src;
in { in {
config = let config = let
inherit (lib) boolToString mkIf; inherit (lib) boolToString mkIf toLower;
# Configs # Configs
inherit (config.vars) hostName; inherit (config.vars) hostName;
@ -70,11 +70,15 @@ in {
home = { home = {
file = let file = let
inherit inherit (import "${self}/lib" {inherit pkgs;}) buildNodeModules;
(import "${self}/lib" {inherit pkgs self;})
buildNodeModules mkType = package: girName: {
buildNodeTypes "${agsConfigDir}/config/types/@girs/${toLower girName}".source =
; pkgs.callPackage
./mk-types {
inherit ts-for-gir-src package girName;
};
};
in ( in (
{ {
# Generated types # Generated types
@ -83,16 +87,8 @@ in {
recursive = true; # To add other types inside the folder recursive = true; # To add other types inside the folder
}; };
} }
// (buildNodeTypes { // (mkType gtkSessionLock "GtkSessionLock-0.1")
pname = "gtk-session-lock"; // (mkType astalTray "AstalTray-0.1")
configPath = "${agsConfigDir}/config/types/@girs";
packages = [gtkSessionLock];
})
// (buildNodeTypes {
pname = "astal-tray";
configPath = "${agsConfigDir}/config/types/@girs";
packages = [astalTray];
})
// { // {
# Out of store symlinks # Out of store symlinks
".config/ags".source = mkOutOfStoreSymlink "${flakeDir}/nixosModules/ags/config"; ".config/ags".source = mkOutOfStoreSymlink "${flakeDir}/nixosModules/ags/config";

View file

@ -1,16 +1,13 @@
{ {
lib, package,
pname, girName,
withGirNames,
buildNpmPackage, buildNpmPackage,
ts-for-gir-src, ts-for-gir-src,
... ...
}: let }:
inherit (lib) concatMapStringsSep;
in
buildNpmPackage { buildNpmPackage {
pname = "${pname}-types"; pname = "${package.pname}-types";
version = "0.0.0"; inherit (package) version;
npmDepsHash = "sha256-8De8tRUKzRhD1jyx0anYNPMhxZyIr2nI45HdK6nb8jI="; npmDepsHash = "sha256-8De8tRUKzRhD1jyx0anYNPMhxZyIr2nI45HdK6nb8jI=";
@ -18,8 +15,8 @@ buildNpmPackage {
dontNpmBuild = true; dontNpmBuild = true;
buildPhase = '' buildPhase = ''
npx @ts-for-gir/cli generate ${concatMapStringsSep " " (p: p.girName) withGirNames} \ npx @ts-for-gir/cli generate ${girName} \
${concatMapStringsSep "\n" (p: "-g ${p.package.dev}/share/gir-1.0 \\") withGirNames} -g ${package.dev}/share/gir-1.0 \
-g ${ts-for-gir-src}/girs \ -g ${ts-for-gir-src}/girs \
--ignoreVersionConflicts \ --ignoreVersionConflicts \
--package \ --package \

View file

@ -1,3 +1,3 @@
@girs @girs/
node_modules node_modules/
tsconfig.json tsconfig.json

View file

@ -1,14 +1,10 @@
import { App } from 'astal'; import { App } from 'astal';
import style from 'inline:./style.scss'; import style from 'inline:./style.scss';
import Bar from './widget/Bar';
import Bar from './widgets/bar/main';
App.start({ App.start({
css: style, css: style,
main() {
main: () => { Bar(0);
Bar();
}, },
}); });

View file

@ -1,15 +1,8 @@
self: { self: {pkgs, ...}: {
lib,
pkgs,
...
}: {
config = let config = let
inherit (lib) attrValues removeAttrs;
inherit (self.inputs) agsV2; inherit (self.inputs) agsV2;
agsV2Packages = agsV2.packages.${pkgs.system}; agsV2Packages = agsV2.packages.${pkgs.system};
astalLibs = attrValues (removeAttrs agsV2.inputs.astal.packages.${pkgs.system} ["docs"]);
configDir = "/home/matt/.nix/nixosModules/ags/v2"; configDir = "/home/matt/.nix/nixosModules/ags/v2";
in { in {
home = { home = {
@ -23,43 +16,27 @@ self: {
}) })
]; ];
file = let file = {
inherit "${configDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" {
(import "${self}/lib" {inherit pkgs self;}) "$schema" = "https://json.schemastore.org/tsconfig";
buildNodeModules "compilerOptions" = {
buildNodeTypes "target" = "ES2023";
; "module" = "ES2022";
in ( "lib" = ["ES2023"];
(buildNodeTypes { "strict" = true;
pname = "agsV2"; "moduleResolution" = "Bundler";
configPath = "${configDir}/@girs"; "skipLibCheck" = true;
packages = astalLibs; "checkJs" = true;
}) "allowJs" = true;
// { "jsx" = "react-jsx";
"${configDir}/node_modules".source = "jsxImportSource" = "${agsV2Packages.astal}/share/astal/gjs/src/jsx";
buildNodeModules ./. "sha256-WjCfS8iEw5Mjor/sQ2t+i0Q1pqVpSDEDbbgrKwK+3cg="; "paths" = {
"astal" = ["${agsV2Packages.astal}/share/astal/gjs"];
"${configDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" { "astal/*" = ["${agsV2Packages.astal}/share/astal/gjs/src/*"];
"$schema" = "https://json.schemastore.org/tsconfig";
"compilerOptions" = {
"target" = "ES2023";
"module" = "ES2022";
"lib" = ["ES2023"];
"strict" = true;
"moduleResolution" = "Bundler";
"skipLibCheck" = true;
"checkJs" = true;
"allowJs" = true;
"jsx" = "react-jsx";
"jsxImportSource" = "${agsV2Packages.astal}/share/astal/gjs/src/jsx";
"paths" = {
"astal" = ["${agsV2Packages.astal}/share/astal/gjs"];
"astal/*" = ["${agsV2Packages.astal}/share/astal/gjs/src/*"];
};
}; };
}; };
} };
); };
}; };
}; };

View file

@ -0,0 +1,39 @@
import { App, Variable, Astal, Gtk } from 'astal';
const time = Variable<string>('').poll(1000, 'date');
/**
* @param monitor the id of the monitor on which we want the widget to appear
* @returns the bar window
*/
export default function Bar(monitor: number) {
return (
<window
className="Bar"
monitor={monitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={
Astal.WindowAnchor.TOP |
Astal.WindowAnchor.LEFT |
Astal.WindowAnchor.RIGHT
}
application={App}
>
<centerbox>
<button
onClicked="echo hello"
halign={Gtk.Align.CENTER}
>
Welcome to AGS!
</button>
<box />
<button
onClick={() => print('hello')}
halign={Gtk.Align.CENTER}
>
<label label={time()} />
</button>
</centerbox>
</window>
);
}

View file

@ -1,30 +0,0 @@
import { App, Astal, Gtk, idle, Variable } from 'astal';
const isVisible = Variable<boolean>(false);
export default () => {
return (
<window
className="Bar"
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={
Astal.WindowAnchor.TOP |
Astal.WindowAnchor.LEFT |
Astal.WindowAnchor.RIGHT
}
application={App}
setup={() => idle(() => {
isVisible.set(true);
})}
>
<revealer
revealChild={isVisible()}
transitionType={Gtk.RevealerTransitionType.SLIDE_DOWN}
transitionDuration={500}
>
<label label="hi" />
</revealer>
</window>
);
};