refactor(greetd): astal -> ags
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-25 23:24:19 -04:00
parent aa979f0fe4
commit 85ff6af1bf
24 changed files with 144 additions and 2368 deletions

View file

@ -90,26 +90,6 @@
"type": "github"
}
},
"astal": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1721074515,
"narHash": "sha256-jTwdQeGHEUMKNI4iIqUpgKbx9kNsY1y7/Vcxi3b2pzQ=",
"owner": "Aylur",
"repo": "Astal",
"rev": "0e2a33b78ebaed008a5d496ab42cd9207cf48db4",
"type": "github"
},
"original": {
"owner": "Aylur",
"repo": "Astal",
"type": "github"
}
},
"astal-tray": {
"inputs": {
"nixpkgs": [
@ -1681,7 +1661,6 @@
"inputs": {
"Hyprspace": "Hyprspace",
"ags": "ags",
"astal": "astal",
"astal-tray": "astal-tray",
"bat-theme-src": "bat-theme-src",
"bazarr-bulk": "bazarr-bulk",

View file

@ -1,4 +1,5 @@
# Do not modify! This file is generated.
{
inputs = {
Hyprspace = {
@ -13,12 +14,6 @@
repo = "ags";
type = "github";
};
astal = {
inputs.nixpkgs.follows = "nixpkgs";
owner = "Aylur";
repo = "Astal";
type = "github";
};
astal-tray = {
inputs.nixpkgs.follows = "nixpkgs";
owner = "astal-sh";
@ -328,4 +323,4 @@
};
};
outputs = inputs: inputs.flakegen ./flake.in.nix inputs;
}
}

View file

@ -162,11 +162,6 @@ let
owner = "Cu3PO42";
repo = "gtk-session-lock";
};
astal = mkDep {
owner = "Aylur";
repo = "Astal";
};
};
};

View file

@ -21,7 +21,7 @@
astalTray = astal-tray.packages.${pkgs.system}.tray;
gtkSessionLock = gtk-session-lock.packages.${pkgs.system}.default;
in {
# Enable pam for ags and astal
# Enable pam for ags
security.pam.services.ags = {};
services.upower.enable = true;
@ -40,6 +40,8 @@ in {
configJs =
# javascript
''
Utils.execAsync('hyprpaper');
import { transpileTypeScript } from './js/utils.js';
export default (await transpileTypeScript('${hostName}')).default;

View file

@ -1,10 +1,11 @@
{
config,
lib,
pkgs,
self,
...
}: let
inherit (config.vars) configDir;
inherit (lib) mkIf;
cursorTheme = self.legacyPackages.${pkgs.system}.dracula.hyprcursor;
cursorThemeName = "Dracula-cursors";
@ -19,31 +20,34 @@ in {
home.file.".local/share/icons/${hyprcursorThemeName}".source = cursorTheme;
wayland.windowManager.hyprland = {
settings = {
envd = [
"XCURSOR_THEME, ${cursorThemeName}"
"XCURSOR_SIZE, ${cursorSize}"
];
settings =
{
envd = [
"XCURSOR_THEME, ${cursorThemeName}"
"XCURSOR_SIZE, ${cursorSize}"
];
exec-once = [
"hyprctl setcursor ${hyprcursorThemeName} ${cursorSize}"
"hyprpaper"
];
exec-once = [
"hyprctl setcursor ${hyprcursorThemeName} ${cursorSize}"
];
windowrule = [
"size 1231 950,title:^(Open Folder)$"
"float,title:^(Open Folder)$"
windowrule = [
"size 1231 950,title:^(Open Folder)$"
"float,title:^(Open Folder)$"
"size 1231 950,title:^(Open File)$"
"float,title:^(Open File)$"
];
"size 1231 950,title:^(Open File)$"
"float,title:^(Open File)$"
];
layerrule = [
"noanim, selection"
];
# This file should only be used for theming
source = ["${configDir}/hypr/main.conf"];
};
layerrule = [
"noanim, selection"
];
}
// (
mkIf (config.home.username != "greeter") {
# This file should only be used for theming
source = ["${config.vars.configDir}/hypr/main.conf"];
}
);
};
}

View file

@ -0,0 +1 @@
../../../ags/config/.envrc

View file

@ -0,0 +1,67 @@
{
ags,
config,
lib,
pkgs,
...
}: let
cfg = config.roles.desktop;
hyprland =
config
.home-manager
.users
.${cfg.user}
.wayland
.windowManager
.hyprland
.finalPackage;
in {
# Add home folder for home-manager to work
users.users.greeter = {
home = "/var/lib/greeter";
createHome = true;
};
home-manager.users.greeter = {
imports = [ags.homeManagerModules.default];
programs.ags.enable = true;
home.packages = [
hyprland
pkgs.gtk3
pkgs.glib
];
xdg.configFile = {
"ags".source = pkgs.stdenv.mkDerivation {
name = "ags-greeter";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./scss
./greeter.ts
./ts
./tsconfig.json
];
};
buildInputs = with pkgs; [
bun
dart-sass
];
buildPhase = ''
sass ./scss/greeter.scss style.css
bun build ./greeter.ts --external resource:///* --external gi://* --external cairo > config.js
'';
installPhase = ''
mkdir $out
mv style.css config.js $out/
'';
};
};
};
}

View file

@ -0,0 +1 @@
../../../ags/config/eslint.config.js

View file

@ -0,0 +1,11 @@
Utils.execAsync('hyprpaper');
import Greeter from './ts/greetd/main.ts';
App.config({
style: './style.css',
windows: () => [
Greeter(),
],
});

View file

@ -0,0 +1 @@
../../../ags/config/package-lock.json

View file

@ -0,0 +1 @@
../../../ags/config/package.json

View file

@ -7,9 +7,6 @@ const { Gtk } = imports.gi;
const DEFAULT_NAME = 'matt';
// Types
import { StringObject } from 'types/@girs/gtk-4.0/gtk-4.0.cjs';
const parsePasswd = (fileContent: string) => {
const splitUsers = fileContent.split('\n');
@ -35,7 +32,11 @@ const parsePasswd = (fileContent: string) => {
};
const users = parsePasswd(await readFileAsync('/etc/passwd'));
const dropdown = Gtk.DropDown.new_from_strings(users.map((u) => u.name));
const dropdown = new Gtk.ComboBoxText();
users.forEach((u) => {
dropdown.append(null, u.name);
});
const password = Entry({
placeholderText: 'Password',
@ -47,7 +48,7 @@ const password = Entry({
on_accept: () => {
greetd.login(
(dropdown.selectedItem as StringObject)['string'] || '',
dropdown.get_active_text() ?? '',
password.text || '',
'Hyprland',
@ -70,7 +71,7 @@ export default () => Window({
vpack: 'center',
hexpand: true,
vexpand: true,
cssClasses: ['base'],
class_names: ['base'],
children: [
Box({
@ -79,23 +80,14 @@ export default () => Window({
vpack: 'center',
hexpand: true,
vexpand: true,
class_names: ['linked'],
setup: (self) => {
self.add_css_class('linked');
setup: () => {
idle(() => {
const usernames = [] as string[];
for (let i = 0; i < dropdown.model.get_n_items(); ++i) {
const name = (dropdown.model.get_item(i) as StringObject)['string'];
if (name) {
usernames.push(name);
}
}
const usernames = users.map((u) => u.name);
if (usernames.includes(DEFAULT_NAME)) {
dropdown.set_selected(usernames.indexOf(DEFAULT_NAME));
dropdown.set_active(usernames.indexOf(DEFAULT_NAME));
}
});
},

View file

@ -2,22 +2,24 @@
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"lib": [
"ES2022"
],
"lib": ["ES2022"],
"noEmit": true,
"allowImportingTsExtensions": true,
"allowSyntheticDefaultImports": true,
"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"]
"fzf": ["./node_modules/fzf/dist/types"]
},
"typeRoots": [
"./types",
"./global-types.d.ts",
"./node_modules"
],
"skipLibCheck": true
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}

View file

@ -1,59 +0,0 @@
{
astal,
config,
pkgs,
...
}: let
cfg = config.roles.desktop;
hyprland =
config
.home-manager
.users
.${cfg.user}
.wayland
.windowManager
.hyprland
.finalPackage;
in {
# Add home folder for home-manager to work
users.users.greeter = {
home = "/var/lib/greeter";
createHome = true;
};
home-manager.users.greeter = {
imports = [
astal.homeManagerModules.default
../home/theme
../home/hyprpaper.nix
];
programs.astal.enable = true;
home.packages = [
hyprland
pkgs.bun
pkgs.dart-sass
pkgs.gtk3
pkgs.glib
];
xdg.configFile = {
"astal" = {
source = ./astal;
recursive = true;
};
"astal/config.js".text =
# javascript
''
import { transpileTypeScript } from './js/utils.js';
Utils.execAsync('hyprpaper');
export default (await transpileTypeScript('greeter')).default;
'';
};
};
}

View file

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

View file

@ -1 +0,0 @@
../../../ags/config/.eslintrc.json

View file

@ -1 +0,0 @@
../../../ags/config/.stylelintrc.yml

View file

@ -1,7 +0,0 @@
import Greeter from './ts/greetd/main';
App.config({
windows: () => [
Greeter(),
],
});

View file

@ -1,47 +0,0 @@
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}; ` +
// Let bun see tsconfig.json
`cd ${App.configDir};` +
`bun build ${App.configDir}/${host}.ts ` +
'--external resource:///* ' +
'--external gi://* ' +
'--external cairo ' +
// Since bun wants to write in cwd, we just redirect stdin instead
`> ${outPath}`,
]).catch(print);
watchAndCompileSass(host);
return await import(`file://${outPath}`);
};

File diff suppressed because it is too large Load diff

View file

@ -1,13 +0,0 @@
{
"main": "config.js",
"dependencies": {
"fzf": "^0.5.2"
},
"devDependencies": {
"@girs/adw-1": "^1.4.3-3.2.9",
"@stylistic/eslint-plugin": "^1.4.0",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.52.0"
}
}

View file

@ -21,7 +21,7 @@
'');
in {
imports = [
./astal.nix
./ags
./hyprland.nix
];

View file

@ -23,6 +23,8 @@
devices = filterAttrs (n: v: hasPrefix "device:" n) cfgHypr.settings;
in {
home-manager.users.greeter = {
imports = [../desktop-environment/home/style.nix];
wayland.windowManager.hyprland = {
enable = true;
package = cfgHypr.finalPackage;
@ -32,17 +34,13 @@ in {
{
inherit (cfgHypr.settings) cursor input misc monitor;
envd =
(optionals (config.nvidia.enable) [
"LIBVA_DRIVER_NAME, nvidia"
"NVD_BACKEND, direct"
"XDG_SESSION_TYPE, wayland"
"GBM_BACKEND, nvidia-drm"
"__GLX_VENDOR_LIBRARY_NAME, nvidia"
])
++ [
"XCURSOR_SIZE,24"
];
envd = optionals (config.nvidia.enable) [
"LIBVA_DRIVER_NAME, nvidia"
"NVD_BACKEND, direct"
"XDG_SESSION_TYPE, wayland"
"GBM_BACKEND, nvidia-drm"
"__GLX_VENDOR_LIBRARY_NAME, nvidia"
];
general.border_size = 0;
@ -52,10 +50,8 @@ in {
};
exec-once = [
"hyprctl setcursor Dracula-cursors 24"
setupMonitors
"astal -b greeter &> /tmp/astal.log; hyprctl dispatch exit"
"ags -b greeter &> /tmp/ags-greetd.log; hyprctl dispatch exit"
];
}
// devices;