forked from catppuccin/sddm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
146 lines (141 loc) Β· 5.19 KB
/
flake.nix
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { flake-utils, self, nixpkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
makePackage = {
cfg ? {
font = "Noto Sans";
fontSize = "9";
clockEnabled = "true";
customBackground = "false";
loginBackground = "false";
background = null;
},
flavour,
lib,
pkgs,
qtbase,
qtsvg,
qtgraphicaleffects,
qtquickcontrols2,
srcPath,
wrapQtAppsHook,
stdenv
}: stdenv.mkDerivation rec {
name = "Catppuccin-${flavour}";
src = ./src/${srcPath};
bg = if cfg.background == null then
null
else if lib.strings.hasPrefix "http" cfg.background then
lib.fetchurl{
url = cfg.background;
}
else if lib.pathExists cfg.background then
lib.fetchfile{
url = cfg.background;
}
else null;
nativeBuildInputs = [
wrapQtAppsHook
pkgs.imagemagick
];
buildInputs = [
qtbase
qtsvg
qtgraphicaleffects
qtquickcontrols2
];
installPhase = ''
mkdir -p $out/share/sddm/themes
if [[ ${if cfg.background == null then "false" else "true"} ]]; then
convert ${toString bg} $out/share/sddm/themes/${name}/backgrounds/wall.jpg
fi
cp -aR $src $out/share/sddm/themes/${name}
'';
postFixup = ''
sed -i '/^Font=/s/.*/Font="${cfg.font}"/' $out/share/sddm/themes/${name}/theme.conf
sed -i '/^FontSize=/s/.*/FontSize="${cfg.fontSize}"/' $out/share/sddm/themes/${name}/theme.conf
sed -i '/^ClockEnabled=/s/.*/ClockEnabled="${cfg.clockEnabled}"/' $out/share/sddm/themes/${name}/theme.conf
sed -i '/^CustomBackground=/s/.*/CustomBackground="${if cfg.background != null then cfg.customBackground else "false"}"/' $out/share/sddm/themes/${name}/theme.conf
sed -i '/^LoginBackground=/s/.*/LoginBackground="${cfg.loginBackground}"/' $out/share/sddm/themes/${name}/theme.conf
'';
meta = {
description = "Catppuccin ${flavour} sddm theme";
license = lib.licenses.gpl3;
};
};
in {
packages = rec {
catppuccin-frappe = pkgs.libsForQt5.callPackage makePackage{
flavour = "Frappe";
srcPath = "catppuccin-frappe";
};
catppuccin-latte = pkgs.libsForQt5.callPackage makePackage {
flavour = "Latte";
srcPath = "catppuccin-latte";
};
catppuccin-macchiato = pkgs.libsForQt5.callPackage makePackage {
flavour = "Macchiato";
srcPath = "catppuccin-macchiato";
};
catppuccin-mocha = pkgs.libsForQt5.callPackage makePackage {
flavour = "Mocha";
srcPath = "catppuccin-mocha";
};
};
nixosModules.${system} = { config, ... }: let
cfg = config.catppuccin-sddm;
in{
options = {
catppuccin-sddm = {
theme = pkgs.lib.mkOption {
type = pkgs.lib.types.str;
default = "mocha";
};
font = {
name = pkgs.lib.mkOption {
type = pkgs.lib.types.str;
default = "Noto Sans";
};
size = pkgs.lib.mkOption {
type = pkgs.lib.types.int;
default = 9;
};
};
clock = pkgs.lib.mkEnableOption true;
background = {
enable = pkgs.lib.mkEnableOption false;
image = pkgs.lib.mkOption {
default = null;
};
login = pkgs.lib.mkOption {
type = pkgs.lib.types.bool;
default = true;
};
};
package = { "frappe" = self.catppuccin-frappe; "latte" = self.catppuccin-latte; "macchiato" = self.catppuccin-macchiato; "mocha" = self.catppuccin-mocha; }.theme;
finalPackage = cfg.package.overrideAttrs {
conf = {
font = cfg.font.name;
fontSize = cfg.font.size;
clockEnabled = cfg.clock;
customBackground = cfg.background.enable;
loginBackground = cfg.background.login;
background = cfg.background.image;
};
};
};
};
config = {
environment.systemPackages = [ cfg.finalPackage ];
services.xserver.displayManager.sddm.theme = { "frappe" = "Catppuccin-Frappe"; "latte" = "Catppuccin-Latte"; "macchiato" = "Catppuccin-Macchiato"; "mocha" = "Catppuccin-Mocha"; }.theme;
};
};
}
);
}