Skip to content

Commit

Permalink
ags: build with derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
brckd committed Mar 30, 2024
1 parent b022249 commit f75916f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion modules/home/ags/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
types

dist/
config.js
12 changes: 9 additions & 3 deletions modules/home/ags/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# AgsDots

## Contributing
## Getting Started

1. Install AGS and Bun.
### Installing AGS and Bun

```bash
home-manager switch --flake .
```

2. Install type definitions.
### Installing type definitions

```bash
bun install
```

### Building

```bash
bun run build
```

## Acknowledgements

This project was created using `bun init` in bun v1.0.33. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Empty file added modules/home/ags/assets/.keep
Empty file.
18 changes: 0 additions & 18 deletions modules/home/ags/config.js

This file was deleted.

7 changes: 7 additions & 0 deletions modules/home/ags/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Bar from "./widget/Bar";

App.addIcons(`${App.configDir}/assets`);
App.config({
windows: [Bar(0)],
style: `${App.configDir}/style/main.css`,
});
29 changes: 19 additions & 10 deletions modules/home/ags/default.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
{
config,
lib,
pkgs,
nixos-symbolic,
...
}:
with lib; let
cfg = config.programs.ags;
colors = config.lib.stylix.colors;
colorNames = map (n: "base${fixedWidthNumber 2 n}") (range 0 16);
in {
config = mkIf cfg.enable {
programs.ags = {
configDir = ./.;
};
xdg.configFile."ags".recursive = true;
configDir = pkgs.stdenv.mkDerivation {
name = "ags-dots";
src = ./.;

nativeBuildInputs = with pkgs; [bun];
buildPhase = ''
# Copy assets
cp ${nixos-symbolic} ./assets/nixos-symbolic.svg
xdg.configFile."ags/src/style/colors.css".text =
concatMapStringsSep "\n"
(color: "@define-color ${color} ${colors.withHashtag.${color}};")
colorNames;
# Build bun files
bun install
bun run build
'';

xdg.configFile."ags/src/assets/nixos-symbolic.svg".source = nixos-symbolic;
installPhase = ''
mkdir -p $out
cp -r assets style config.js $out
'';
};
};
};
}
3 changes: 2 additions & 1 deletion modules/home/ags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"typescript": "^5.0.0"
},
"scripts": {
"postinstall": "rm types; ln -s $HOME/.local/share/com.github.Aylur.ags/types types"
"postinstall": "rm types; ln -s $HOME/.local/share/com.github.Aylur.ags/types types",
"build": "bun build ./config.ts --outfile ./config.js --external \"resource://*\" --external \"gi://*\""
}
}
7 changes: 0 additions & 7 deletions modules/home/ags/src/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion modules/home/ags/src/style/global.css

This file was deleted.

Empty file added modules/home/ags/style/main.css
Empty file.
File renamed without changes.

0 comments on commit f75916f

Please sign in to comment.