about summary refs log tree commit diff
path: root/modules/workstation/windowing/sway/default.nix
blob: d0e7e556fc5255ec993076c8c88591a1f69e5bad (plain) (blame)
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
62
63
64
65
66
{ pkgs, lib, config, ... }:

let
  inherit (lib) mkOption optionalString;
  inherit (lib.types) lines nullOr path;
in

{
  imports = [ ./swayidle ./swaylock ];

  options = {
    programs.sway.extraConfig = mkOption {
      type = lines;
      description = "Lines to append to sway's config file";
      default = "";
    };

    programs.sway.wallpaper = mkOption {
      type = nullOr path;
      description = "Path to wallpaper for sway and swaylock";
      default = null;
    };
  };

  config = let
    cfg = config.programs.sway;

    configFile = pkgs.substituteAll {
      src = ./config.in;
      inherit choose_workspace status_command;
      extraConfig = cfg.extraConfig + optionalString (cfg.wallpaper != null) ''
        output * bg ${cfg.wallpaper} fill
      '';
    };

    status_command = "${pkgs.runCommandCC "status" {} ''
      mkdir -p $out/bin
      c++ -std=c++17 -o $out/bin/status ${./status.cpp}
    ''}/bin/status";

    choose_workspace = pkgs.substituteAll {
      src = ./choose_workspace.sh.in;
      isExecutable = true;
      inherit (pkgs) bemenu jq;
    };

  in

  {
    environment.systemPackages = with pkgs; [ bemenu choose ];

    programs.sway.enable = true;
    programs.sway.wallpaper = pkgs.fetchurl {
      url = https://mir-s3-cdn-cf.behance.net/project_modules/2800_opt_1/36731876964505.5c793fa788b5d.jpg;
      sha256 = "1c6camdipng8ws41sgpcxzrxb96crgip3wirqjgf2ajn60qg3v64";

      meta = {
        homepage = https://www.behance.net/gallery/76964505/IQOO-style-frame-and-scene-design;
      };
    };

    programs.swayidle.enable = true;

    users.users.qyliss.xdg.config.paths."sway/config" = configFile;
  };
}