summaryrefslogtreecommitdiff
path: root/pkgs/astal/default.nix
blob: fb320eececa3014c6701aac052c586c7bcf5e6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
  pkgs,
  inputs,
  system,
  options,
  ...
}: let
  runCommand = pkgs.runCommand;
  dart-sass = pkgs.dart-sass;

  apkgs = inputs.astal.packages.${system};
  scss = "${dart-sass}/bin/sass";
  theme = import ./theme.nix {inherit options;};

  mkAstal = file:
    inputs.astal.lib.mkLuaPackage {
      pkgs =
        pkgs
        // {
          # use luajit
          lua = pkgs.luajit;
        };
      src = runCommand "src" {} ''
        mkdir -p $out
        cp -r ${./src}/{*.lua,widget} $out/
        cp $out/${file}.lua $out/init.lua
        cp -r ${./src}/style/* .
        echo '${theme}' > theme.scss
        cat theme.scss style.scss widget/* > main.scss
        ${scss} main.scss $out/main.css
      '';
      name = "astal-${file}";
      extraPackages =
        (with apkgs; [
          apps
          battery
          hyprland
          mpris
          network
          notifd
          tray
          wireplumber
        ])
        ++ (with pkgs; [
          networkmanager
        ]);
    };

  mkAstalWrapper = file: let
    pkg = mkAstal file;
  in
    pkgs.writeShellApplication {
      name = "astal-${file}";
      text = ''
        ${pkg}/bin/astal-${file}
      '';
    };
in {
  shell = mkAstalWrapper "shell";
  launcher = mkAstalWrapper "launcher";
}