feat(ags): prepare env for agsV2
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-09-23 23:52:17 -04:00
parent bc4470feb2
commit aa9723303b
15 changed files with 605 additions and 3 deletions

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -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";

View file

@ -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 {

View file

@ -58,6 +58,8 @@ in {
}
];
imports = [(import ./v2 self)];
programs.ags = {
enable = true;
extraPackages = [

View file

@ -0,0 +1 @@
use flake "$FLAKE#node"

3
nixosModules/ags/v2/.gitignore vendored Normal file
View file

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

View file

@ -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);
},
});

View file

@ -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;
}

26
nixosModules/ags/v2/env.d.ts vendored Normal file
View file

@ -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;
}

View file

@ -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',
],
},
});

BIN
nixosModules/ags/v2/package-lock.json generated Normal file

Binary file not shown.

View file

@ -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"
}
}

View file

@ -0,0 +1 @@

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>
);
}