From 62dc1214e9ada4e66dac215bb6635ec49e6a2417 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 24 Sep 2024 16:19:56 -0400 Subject: [PATCH] feat(agsv2): add node_modules and types with nix --- nixosModules/ags/v2/.gitignore | 4 +- nixosModules/ags/v2/app.ts | 10 ++-- nixosModules/ags/v2/default.nix | 63 ++++++++++++++++-------- nixosModules/ags/v2/widget/Bar.tsx | 39 --------------- nixosModules/ags/v2/widgets/bar/main.tsx | 30 +++++++++++ 5 files changed, 82 insertions(+), 64 deletions(-) delete mode 100644 nixosModules/ags/v2/widget/Bar.tsx create mode 100644 nixosModules/ags/v2/widgets/bar/main.tsx diff --git a/nixosModules/ags/v2/.gitignore b/nixosModules/ags/v2/.gitignore index 701427d2..be93e7dc 100644 --- a/nixosModules/ags/v2/.gitignore +++ b/nixosModules/ags/v2/.gitignore @@ -1,3 +1,3 @@ -@girs/ -node_modules/ +@girs +node_modules tsconfig.json diff --git a/nixosModules/ags/v2/app.ts b/nixosModules/ags/v2/app.ts index 4dd48642..fc0508dc 100644 --- a/nixosModules/ags/v2/app.ts +++ b/nixosModules/ags/v2/app.ts @@ -1,10 +1,14 @@ import { App } from 'astal'; + import style from 'inline:./style.scss'; -import Bar from './widget/Bar'; + +import Bar from './widgets/bar/main'; + App.start({ css: style, - main() { - Bar(0); + + main: () => { + Bar(); }, }); diff --git a/nixosModules/ags/v2/default.nix b/nixosModules/ags/v2/default.nix index ab7b3280..0268b736 100644 --- a/nixosModules/ags/v2/default.nix +++ b/nixosModules/ags/v2/default.nix @@ -1,8 +1,15 @@ -self: {pkgs, ...}: { +self: { + lib, + pkgs, + ... +}: { config = let + inherit (lib) attrValues removeAttrs; + inherit (self.inputs) agsV2; agsV2Packages = agsV2.packages.${pkgs.system}; + astalLibs = attrValues (removeAttrs agsV2.inputs.astal.packages.${pkgs.system} ["docs"]); configDir = "/home/matt/.nix/nixosModules/ags/v2"; in { home = { @@ -16,27 +23,43 @@ self: {pkgs, ...}: { }) ]; - file = { - "${configDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" { - "$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/*"]; + file = let + inherit + (import "${self}/lib" {inherit pkgs self;}) + buildNodeModules + buildNodeTypes + ; + in ( + (buildNodeTypes { + pname = "agsV2"; + configPath = "${configDir}/@girs"; + packages = astalLibs; + }) + // { + "${configDir}/node_modules".source = + buildNodeModules ./. "sha256-WjCfS8iEw5Mjor/sQ2t+i0Q1pqVpSDEDbbgrKwK+3cg="; + + "${configDir}/tsconfig.json".source = pkgs.writers.writeJSON "tsconfig.json" { + "$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/*"]; + }; }; }; - }; - }; + } + ); }; }; diff --git a/nixosModules/ags/v2/widget/Bar.tsx b/nixosModules/ags/v2/widget/Bar.tsx deleted file mode 100644 index 83d93be3..00000000 --- a/nixosModules/ags/v2/widget/Bar.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { App, Variable, Astal, Gtk } from 'astal'; - -const time = Variable('').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 ( - - - - - - - - ); -} diff --git a/nixosModules/ags/v2/widgets/bar/main.tsx b/nixosModules/ags/v2/widgets/bar/main.tsx new file mode 100644 index 00000000..0a950c6d --- /dev/null +++ b/nixosModules/ags/v2/widgets/bar/main.tsx @@ -0,0 +1,30 @@ +import { App, Astal, Gtk, idle, Variable } from 'astal'; + + +const isVisible = Variable(false); + +export default () => { + return ( + idle(() => { + isVisible.set(true); + })} + > + + + + ); +};