diff --git a/flake.lock b/flake.lock index f0b367cf..f10bcd4a 100644 Binary files a/flake.lock and b/flake.lock differ diff --git a/flake.nix b/flake.nix index 64213eb6..bec63ff1 100644 Binary files a/flake.nix and b/flake.nix differ diff --git a/inputs.nix b/inputs.nix index 276c2d43..828b6dc8 100644 --- a/inputs.nix +++ b/inputs.nix @@ -1,6 +1,6 @@ let - inherit (import ./lib {}) lib mkDep mkInput mkHyprDep mkSrc; - inherit (lib) listToAttrs map removeAttrs; + inherit (import ./lib {}) mkDep mkInput mkHyprDep mkSrc; + inherit (builtins) listToAttrs map removeAttrs; # Inputs nixTools = { @@ -150,6 +150,12 @@ let repo = "ags"; }; + agsV2 = mkDep { + owner = "Aylur"; + repo = "ags"; + ref = "v2"; + }; + astal = mkDep { owner = "Aylur"; repo = "astal"; diff --git a/lib/inputs.nix b/lib/inputs.nix index 3282a33f..d44130af 100644 --- a/lib/inputs.nix +++ b/lib/inputs.nix @@ -1,5 +1,6 @@ lib: lock: let - inherit (lib) attrValues findFirst foldl' hasAttr matchAttrs optionalAttrs recursiveUpdate removeAttrs; + inherit (lib) attrValues findFirst foldl' hasAttr matchAttrs optionalAttrs recursiveUpdate; + inherit (builtins) removeAttrs; recursiveUpdateList = list: foldl' recursiveUpdate {} list; in rec { diff --git a/nixosModules/ags/default.nix b/nixosModules/ags/default.nix index 6229991a..a61a7f07 100644 --- a/nixosModules/ags/default.nix +++ b/nixosModules/ags/default.nix @@ -58,6 +58,8 @@ in { } ]; + imports = [(import ./v2 self)]; + programs.ags = { enable = true; extraPackages = [ diff --git a/nixosModules/ags/v2/.envrc b/nixosModules/ags/v2/.envrc new file mode 100644 index 00000000..674cafba --- /dev/null +++ b/nixosModules/ags/v2/.envrc @@ -0,0 +1 @@ +use flake "$FLAKE#node" diff --git a/nixosModules/ags/v2/.gitignore b/nixosModules/ags/v2/.gitignore new file mode 100644 index 00000000..701427d2 --- /dev/null +++ b/nixosModules/ags/v2/.gitignore @@ -0,0 +1,3 @@ +@girs/ +node_modules/ +tsconfig.json diff --git a/nixosModules/ags/v2/app.ts b/nixosModules/ags/v2/app.ts new file mode 100644 index 00000000..4dd48642 --- /dev/null +++ b/nixosModules/ags/v2/app.ts @@ -0,0 +1,10 @@ +import { App } from 'astal'; +import style from 'inline:./style.scss'; +import Bar from './widget/Bar'; + +App.start({ + css: style, + main() { + Bar(0); + }, +}); diff --git a/nixosModules/ags/v2/default.nix b/nixosModules/ags/v2/default.nix new file mode 100644 index 00000000..ab7b3280 --- /dev/null +++ b/nixosModules/ags/v2/default.nix @@ -0,0 +1,45 @@ +self: {pkgs, ...}: { + config = let + inherit (self.inputs) agsV2; + + agsV2Packages = agsV2.packages.${pkgs.system}; + configDir = "/home/matt/.nix/nixosModules/ags/v2"; + in { + home = { + packages = [ + (pkgs.writeShellApplication { + name = "agsV2"; + runtimeInputs = []; + text = '' + exec ${agsV2Packages.agsFull}/bin/ags --config ${configDir} "$@" + ''; + }) + ]; + + 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/*"]; + }; + }; + }; + }; + }; + }; + + # For accurate stack trace + _file = ./default.nix; +} diff --git a/nixosModules/ags/v2/env.d.ts b/nixosModules/ags/v2/env.d.ts new file mode 100644 index 00000000..0c89cd4b --- /dev/null +++ b/nixosModules/ags/v2/env.d.ts @@ -0,0 +1,26 @@ +/* eslint-disable-next-line @typescript-eslint/no-unused-vars */ +const SRC: string; + +declare module 'inline:*' { + const content: string; + + export default content; +} + +declare module '*.sass' { + const content: string; + + export default content; +} + +declare module '*.scss' { + const content: string; + + export default content; +} + +declare module '*.css' { + const content: string; + + export default content; +} diff --git a/nixosModules/ags/v2/eslint.config.ts b/nixosModules/ags/v2/eslint.config.ts new file mode 100644 index 00000000..0a3eea06 --- /dev/null +++ b/nixosModules/ags/v2/eslint.config.ts @@ -0,0 +1,452 @@ +import eslint from '@eslint/js'; +import jsdoc from 'eslint-plugin-jsdoc'; +import stylistic from '@stylistic/eslint-plugin'; +import tseslint from 'typescript-eslint'; + + +export default tseslint.config({ + files: ['**/*.{js,ts,tsx}'], + ignores: ['node_modules/**', 'types/**'], + + extends: [ + eslint.configs.recommended, + jsdoc.configs['flat/recommended-typescript'], + stylistic.configs['recommended-flat'], + ...tseslint.configs.recommended, + ...tseslint.configs.stylistic, + ], + + rules: { + // JSDoc settings + 'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }], + 'jsdoc/check-line-alignment': ['warn', 'always', { + tags: ['param', 'arg', 'argument', 'property', 'prop'], + }], + 'jsdoc/no-types': 'off', + + // Newer settings + '@typescript-eslint/no-extraneous-class': ['off'], + '@typescript-eslint/no-implied-eval': ['off'], + 'class-methods-use-this': 'off', + '@stylistic/no-multiple-empty-lines': 'off', + '@stylistic/jsx-indent-props': 'off', + + // Pre-flat config + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + + 'array-callback-return': [ + 'error', + { + allowImplicit: true, + checkForEach: true, + }, + ], + 'no-constructor-return': [ + 'error', + ], + 'no-unreachable-loop': [ + 'error', + { + ignore: [ + 'ForInStatement', + 'ForOfStatement', + ], + }, + ], + 'no-use-before-define': [ + 'error', + { + functions: false, + }, + ], + 'block-scoped-var': [ + 'error', + ], + 'curly': [ + 'warn', + ], + 'default-case-last': [ + 'warn', + ], + 'default-param-last': [ + 'error', + ], + 'eqeqeq': [ + 'error', + 'smart', + ], + 'func-names': [ + 'warn', + 'never', + ], + 'func-style': [ + 'warn', + 'expression', + ], + 'logical-assignment-operators': [ + 'warn', + 'always', + ], + 'no-array-constructor': [ + 'error', + ], + 'no-empty-function': [ + 'warn', + ], + 'no-empty-static-block': [ + 'warn', + ], + 'no-extend-native': [ + 'error', + ], + 'no-extra-bind': [ + 'warn', + ], + 'no-implicit-coercion': [ + 'warn', + ], + 'no-iterator': [ + 'error', + ], + 'no-labels': [ + 'error', + ], + 'no-lone-blocks': [ + 'error', + ], + 'no-lonely-if': [ + 'error', + ], + 'no-loop-func': [ + 'error', + ], + 'no-magic-numbers': [ + 'error', + { + ignore: [ + -1, + 0.1, + 0, + 1, + 2, + 3, + 4, + 5, + 10, + 12, + 33, + 66, + 100, + 255, + 360, + 450, + 500, + 1000, + ], + ignoreDefaultValues: true, + ignoreClassFieldInitialValues: true, + }, + ], + 'no-multi-assign': [ + 'error', + ], + 'no-new-wrappers': [ + 'error', + ], + 'no-object-constructor': [ + 'error', + ], + 'no-proto': [ + 'error', + ], + 'no-return-assign': [ + 'error', + ], + 'no-sequences': [ + 'error', + ], + 'no-shadow': [ + 'error', + { + builtinGlobals: true, + allow: [ + 'Window', + ], + }, + ], + 'no-undef-init': [ + 'warn', + ], + 'no-undefined': [ + 'error', + ], + 'no-useless-constructor': [ + 'warn', + ], + 'no-useless-escape': [ + 'off', + ], + 'no-useless-return': [ + 'error', + ], + 'no-var': [ + 'error', + ], + 'no-void': [ + 'off', + ], + 'no-with': [ + 'error', + ], + 'object-shorthand': [ + 'error', + 'always', + ], + 'one-var': [ + 'error', + 'never', + ], + 'operator-assignment': [ + 'warn', + 'always', + ], + 'prefer-arrow-callback': [ + 'error', + ], + 'prefer-const': [ + 'error', + ], + 'prefer-object-has-own': [ + 'error', + ], + 'prefer-regex-literals': [ + 'error', + ], + 'prefer-template': [ + 'warn', + ], + 'no-prototype-builtins': 'off', + '@typescript-eslint/no-var-requires': [ + 'off', + ], + '@stylistic/array-bracket-newline': [ + 'warn', + 'consistent', + ], + '@stylistic/array-bracket-spacing': [ + 'warn', + 'never', + ], + '@stylistic/arrow-parens': [ + 'warn', + 'always', + ], + '@stylistic/brace-style': [ + 'warn', + 'stroustrup', + ], + '@stylistic/comma-dangle': [ + 'warn', + 'always-multiline', + ], + '@stylistic/comma-spacing': [ + 'warn', + { + before: false, + after: true, + }, + ], + '@stylistic/comma-style': [ + 'error', + 'last', + ], + '@stylistic/dot-location': [ + 'error', + 'property', + ], + '@stylistic/function-call-argument-newline': [ + 'warn', + 'consistent', + ], + '@stylistic/function-paren-newline': [ + 'warn', + 'consistent', + ], + '@stylistic/indent': [ + 'warn', + 4, + { + SwitchCase: 1, + ignoreComments: true, + ignoredNodes: ['TemplateLiteral > *'], + }, + ], + '@stylistic/key-spacing': [ + 'warn', + { + beforeColon: false, + afterColon: true, + }, + ], + '@stylistic/keyword-spacing': [ + 'warn', + { + before: true, + }, + ], + '@stylistic/linebreak-style': [ + 'error', + 'unix', + ], + '@stylistic/lines-between-class-members': [ + 'warn', + 'always', + { + exceptAfterSingleLine: true, + }, + ], + '@stylistic/max-len': [ + 'warn', + { + code: 105, + ignoreComments: true, + ignoreTrailingComments: true, + ignoreUrls: true, + }, + ], + '@stylistic/multiline-ternary': [ + 'warn', + 'always-multiline', + ], + '@stylistic/new-parens': [ + 'error', + ], + '@stylistic/no-mixed-operators': [ + 'warn', + ], + '@stylistic/no-mixed-spaces-and-tabs': [ + 'error', + ], + '@stylistic/no-multi-spaces': [ + 'error', + ], + '@stylistic/no-tabs': [ + 'error', + ], + '@stylistic/no-trailing-spaces': [ + 'error', + ], + '@stylistic/no-whitespace-before-property': [ + 'warn', + ], + '@stylistic/nonblock-statement-body-position': [ + 'error', + 'below', + ], + '@stylistic/object-curly-newline': [ + 'warn', + { + consistent: true, + }, + ], + '@stylistic/object-curly-spacing': [ + 'warn', + 'always', + ], + '@stylistic/operator-linebreak': [ + 'warn', + 'after', + ], + '@stylistic/padded-blocks': [ + 'error', + 'never', + ], + '@stylistic/padding-line-between-statements': [ + 'warn', + { + blankLine: 'always', + prev: '*', + next: 'return', + }, + { + blankLine: 'always', + prev: [ + 'const', + 'let', + 'var', + ], + next: '*', + }, + { + blankLine: 'any', + prev: [ + 'const', + 'let', + 'var', + ], + next: [ + 'const', + 'let', + 'var', + ], + }, + { + blankLine: 'always', + prev: [ + 'case', + 'default', + ], + next: '*', + }, + ], + '@stylistic/quote-props': [ + 'error', + 'consistent-as-needed', + ], + '@stylistic/quotes': [ + 'error', + 'single', + { + avoidEscape: true, + }, + ], + '@stylistic/semi': [ + 'error', + 'always', + ], + '@stylistic/semi-spacing': [ + 'warn', + ], + '@stylistic/space-before-blocks': [ + 'warn', + ], + '@stylistic/space-before-function-paren': [ + 'warn', + 'never', + ], + '@stylistic/space-infix-ops': [ + 'warn', + ], + '@stylistic/spaced-comment': [ + 'warn', + 'always', + ], + '@stylistic/switch-colon-spacing': [ + 'warn', + ], + '@stylistic/wrap-regex': [ + 'warn', + ], + }, +}); diff --git a/nixosModules/ags/v2/package-lock.json b/nixosModules/ags/v2/package-lock.json new file mode 100644 index 00000000..18213386 Binary files /dev/null and b/nixosModules/ags/v2/package-lock.json differ diff --git a/nixosModules/ags/v2/package.json b/nixosModules/ags/v2/package.json new file mode 100644 index 00000000..09c32a46 --- /dev/null +++ b/nixosModules/ags/v2/package.json @@ -0,0 +1,16 @@ +{ + "name": "ags-v2", + "version": "0.0.0", + "main": "app.ts", + "dependencies": { + "@eslint/js": "9.11.1", + "@stylistic/eslint-plugin": "2.8.0", + "@types/eslint__js": "8.42.3", + "@types/node": "22.6.0", + "eslint": "9.11.1", + "eslint-plugin-jsdoc": "50.2.4", + "jiti": "1.21.6", + "typescript": "5.6.2", + "typescript-eslint": "8.7.0" + } +} diff --git a/nixosModules/ags/v2/style.scss b/nixosModules/ags/v2/style.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/nixosModules/ags/v2/style.scss @@ -0,0 +1 @@ + diff --git a/nixosModules/ags/v2/widget/Bar.tsx b/nixosModules/ags/v2/widget/Bar.tsx new file mode 100644 index 00000000..83d93be3 --- /dev/null +++ b/nixosModules/ags/v2/widget/Bar.tsx @@ -0,0 +1,39 @@ +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 ( + + + + + + + + ); +}