-
Notifications
You must be signed in to change notification settings - Fork 43
/
flake.nix
121 lines (112 loc) · 3.56 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
{
description = "flake support minegrub theme nixos module";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
inherit (nixpkgs.lib) genAttrs optional;
eachSystem = f: genAttrs
[
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
]
(system: f nixpkgs.legacyPackages.${system});
minegrub =
{ pkgs, splash ? "", background ? "", customSplash ? splash != "", boot-options-count, ... }:
pkgs.stdenv.mkDerivation {
name = "minegrub-theme";
src = "${self}";
buildInputs = with pkgs; optional customSplash
[
fastfetch
(python3.withPackages
(p: [ p.pillow ]))
];
patchPhase = ''
sed -i '$d' minegrub/update_theme.py
top_value=$((170 + (${toString boot-options-count} - 2) * 72))
sed -i '/^+ image {/,/^}$/s/top = 40%+[0-9]\+/top = 40%+'"$top_value"'/' minegrub/theme.txt
'';
buildPhase = optional customSplash ''
python minegrub/update_theme.py "${background}" "${splash}"
'';
installPhase = ''
cd minegrub
mkdir -p $out/grub/themes/minegrub
cp *.png $out/grub/themes/minegrub
cp *.pf2 $out/grub/themes/minegrub
cp theme.txt $out/grub/themes/minegrub
'';
};
in
{
nixosModules.default = { config, pkgs, ... }:
let
cfg = config.boot.loader.grub.minegrub-theme;
inherit (nixpkgs.lib) mkOption types mkIf;
in
{
options = {
boot.loader.grub.minegrub-theme = {
boot-options-count = mkOption {
default = 4;
example = 4;
type = types.number;
description = ''
Number of boot options.
'';
};
splash = mkOption {
default = "deleting garbage...";
example = "Infinite recursion";
type = types.str;
description = ''
Splash text on logo.
'';
};
background = mkOption {
default = "background_options/1.8 - [Classic Minecraft].png";
example = "/path/to/background.png";
type = types.str;
description = ''
Path to background image.
'';
};
enable = mkOption {
default = false;
example = true;
type = types.bool;
description = ''
Enable minegrub theme.
'';
};
};
};
config = mkIf cfg.enable {
boot.loader.grub =
let
minegrub-theme = minegrub {
inherit pkgs;
splash = cfg.splash;
background = cfg.background;
boot-options-count = cfg.boot-options-count;
};
in
{
theme = "${minegrub-theme}/grub/themes/minegrub";
splashImage = "${minegrub-theme}/grub/themes/minegrub/background.png";
};
};
};
packages = eachSystem
(pkgs: {
default = minegrub {
inherit pkgs;
# splash = "custom splash text";
};
});
};
}