Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit cdafe9e

Browse files
committed
chore: formatting
1 parent 37c4968 commit cdafe9e

18 files changed

+664
-617
lines changed

flake.nix

+63-65
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,21 @@
77
flake-utils.url = "github:numtide/flake-utils";
88
};
99

10-
outputs = {
11-
self,
12-
nixpkgs,
13-
flake-utils,
14-
...
15-
}:
10+
outputs =
11+
{
12+
self,
13+
nixpkgs,
14+
flake-utils,
15+
...
16+
}:
1617
{
1718
homeManagerModules = {
18-
spicetify = (import ./module.nix) {
19-
isNixOSModule = false;
20-
};
19+
spicetify = (import ./module.nix) { isNixOSModule = false; };
2120
default = self.homeManagerModules.spicetify;
2221
};
2322

2423
nixosModules = {
25-
spicetify = import ./module.nix {
26-
isNixOSModule = true;
27-
};
24+
spicetify = import ./module.nix { isNixOSModule = true; };
2825
default = self.nixosModules.spicetify;
2926
};
3027

@@ -40,66 +37,67 @@
4037
# legacy stuff thats just for x86_64 linux
4138
// (
4239
let
43-
legacyPkgs = import nixpkgs {system = flake-utils.lib.system.x86_64-linux;};
44-
in {
40+
legacyPkgs = import nixpkgs { system = flake-utils.lib.system.x86_64-linux; };
41+
in
42+
{
4543
pkgs =
46-
nixpkgs.lib.warn
47-
"spicetify-nix.pkgs is deprecated, use spicetify-nix.packages.\${pkgs.system}"
48-
(legacyPkgs.callPackage ./pkgs {});
49-
lib =
50-
nixpkgs.lib.warn
51-
"spicetify-nix.lib is deprecated, use spicetify-nix.libs.\${pkgs.system}"
52-
(legacyPkgs.callPackage ./lib {});
44+
nixpkgs.lib.warn "spicetify-nix.pkgs is deprecated, use spicetify-nix.packages.\${pkgs.system}"
45+
(legacyPkgs.callPackage ./pkgs { });
46+
lib = nixpkgs.lib.warn "spicetify-nix.lib is deprecated, use spicetify-nix.libs.\${pkgs.system}" (
47+
legacyPkgs.callPackage ./lib { }
48+
);
5349
}
5450
)
55-
// flake-utils.lib.eachSystem
56-
(
57-
let
58-
inherit (flake-utils.lib) system;
59-
in [
60-
system.aarch64-linux
61-
system.x86_64-linux
62-
]
63-
)
64-
(system: let
65-
pkgs = import nixpkgs {inherit system;};
66-
in {
67-
libs = pkgs.callPackage ./lib {};
51+
//
52+
flake-utils.lib.eachSystem
53+
(
54+
let
55+
inherit (flake-utils.lib) system;
56+
in
57+
[
58+
system.aarch64-linux
59+
system.x86_64-linux
60+
]
61+
)
62+
(
63+
system:
64+
let
65+
pkgs = import nixpkgs { inherit system; };
66+
in
67+
{
68+
libs = pkgs.callPackage ./lib { };
6869

69-
packages = {
70-
spicetify = pkgs.callPackage ./pkgs {};
71-
default = self.packages.${system}.spicetify;
72-
};
70+
packages = {
71+
spicetify = pkgs.callPackage ./pkgs { };
72+
default = self.packages.${system}.spicetify;
73+
};
7374

74-
checks = {
75-
all-tests = pkgs.callPackage ./tests {};
76-
minimal-config = pkgs.callPackage ./tests/minimal-config.nix {};
77-
all-for-theme = pkgs.callPackage ./tests/all-for-theme.nix {};
78-
apps = pkgs.callPackage ./tests/apps.nix {};
79-
default = self.checks.${system}.all-tests;
80-
all-exts-and-apps =
81-
builtins.mapAttrs
82-
(_: value: self.checks.${system}.all-for-theme value)
83-
(builtins.removeAttrs
84-
(pkgs.callPackage ./pkgs {}).themes
85-
["override" "overrideDerivation"]);
86-
};
75+
checks = {
76+
all-tests = pkgs.callPackage ./tests { };
77+
minimal-config = pkgs.callPackage ./tests/minimal-config.nix { };
78+
all-for-theme = pkgs.callPackage ./tests/all-for-theme.nix { };
79+
apps = pkgs.callPackage ./tests/apps.nix { };
80+
default = self.checks.${system}.all-tests;
81+
all-exts-and-apps = builtins.mapAttrs (_: value: self.checks.${system}.all-for-theme value) (
82+
builtins.removeAttrs (pkgs.callPackage ./pkgs { }).themes [
83+
"override"
84+
"overrideDerivation"
85+
]
86+
);
87+
};
8788

88-
formatter = pkgs.alejandra;
89+
formatter = pkgs.alejandra;
8990

90-
# DEPRECATED ---------------------------------------------------------------
91+
# DEPRECATED ---------------------------------------------------------------
9192

92-
pkgSets =
93-
nixpkgs.lib.warn
94-
"spicetify-nix.pkgSets is deprecated, use spicetify-nix.packages.\${pkgs.system}.default"
95-
self.packages.${system}.default;
93+
pkgSets =
94+
nixpkgs.lib.warn
95+
"spicetify-nix.pkgSets is deprecated, use spicetify-nix.packages.\${pkgs.system}.default"
96+
self.packages.${system}.default;
9697

97-
devShells = {
98-
default = pkgs.mkShell {
99-
packages = [
100-
pkgs.nvfetcher
101-
];
102-
};
103-
};
104-
});
98+
devShells = {
99+
default = pkgs.mkShell { packages = [ pkgs.nvfetcher ]; };
100+
};
101+
}
102+
);
105103
}

lib/default.nix

+79-92
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,98 @@
1+
{ callPackage, lib, ... }:
2+
let
3+
spicePkgs = callPackage ../pkgs { };
4+
in
15
{
2-
callPackage,
3-
lib,
4-
...
5-
}: let
6-
spicePkgs = callPackage ../pkgs {};
7-
in {
8-
types = callPackage ./types.nix {};
6+
types = callPackage ./types.nix { };
97

108
createXpuiINI = lib.generators.toINI {
119
# specifies how to format a key/value pair
12-
mkKeyValue =
13-
lib.generators.mkKeyValueDefault
14-
{
15-
# specifies the generated string for a subset of nix values
16-
mkValueString = v:
17-
if v == true
18-
then "1"
19-
else if v == false
20-
then "0"
21-
# else if isString v then ''"${v}"''
22-
# and delegates all other values to the default generator
23-
else lib.generators.mkValueStringDefault {} v;
24-
} "=";
10+
mkKeyValue = lib.generators.mkKeyValueDefault {
11+
# specifies the generated string for a subset of nix values
12+
mkValueString =
13+
v:
14+
if v == true then
15+
"1"
16+
else if v == false then
17+
"0"
18+
# else if isString v then ''"${v}"''
19+
# and delegates all other values to the default generator
20+
else
21+
lib.generators.mkValueStringDefault { } v;
22+
} "=";
2523
};
2624

27-
spicetifyBuilder = callPackage ./spicetify-builder.nix {};
25+
spicetifyBuilder = callPackage ./spicetify-builder.nix { };
2826

29-
xpuiBuilder = callPackage ./xpui-builder.nix {};
27+
xpuiBuilder = callPackage ./xpui-builder.nix { };
3028

31-
getThemePath = theme:
32-
if (builtins.hasAttr "appendName" theme)
33-
then
34-
(
35-
if theme.appendName
36-
then "${theme.src}/${theme.name}"
37-
else theme.src
38-
)
39-
else theme.src;
29+
getThemePath =
30+
theme:
31+
if (builtins.hasAttr "appendName" theme) then
32+
(if theme.appendName then "${theme.src}/${theme.name}" else theme.src)
33+
else
34+
theme.src;
4035

4136
# same thing but if its a string it looks it up in the default pkgs
42-
getTheme = theme:
43-
if builtins.typeOf theme == "string"
44-
then
37+
getTheme =
38+
theme:
39+
if builtins.typeOf theme == "string" then
4540
(
46-
if builtins.hasAttr theme spicePkgs.themes
47-
then
48-
(lib.trivial.warn
49-
''
50-
Using a string like so:
51-
programs.spicetify.theme = "${theme}";
52-
is deprecated. Please use the following format:
53-
programs.spicetify.theme = let
54-
spicePkgs = spicetify-nix.packages.${"$\{pkgs.system}"}.default;
55-
in
56-
spicePkgs.themes.${theme};
57-
''
58-
spicePkgs.themes.${theme})
59-
else throw "Unknown theme ${theme}. Try using the lib.theme type instead of a string."
41+
if builtins.hasAttr theme spicePkgs.themes then
42+
(lib.trivial.warn ''
43+
Using a string like so:
44+
programs.spicetify.theme = "${theme}";
45+
is deprecated. Please use the following format:
46+
programs.spicetify.theme = let
47+
spicePkgs = spicetify-nix.packages.${"$\{pkgs.system}"}.default;
48+
in
49+
spicePkgs.themes.${theme};
50+
'' spicePkgs.themes.${theme})
51+
else
52+
throw "Unknown theme ${theme}. Try using the lib.theme type instead of a string."
6053
)
61-
else if theme == null
62-
then
63-
lib.trivial.warn
64-
"spicetify: null theme passed to getTheme, assuming official.Default"
65-
spicePkgs.themes.official.Default
66-
else theme;
54+
else if theme == null then
55+
lib.trivial.warn "spicetify: null theme passed to getTheme, assuming official.Default" spicePkgs.themes.official.Default
56+
else
57+
theme;
6758

68-
getExtension = ext:
69-
if builtins.typeOf ext == "string"
70-
then
59+
getExtension =
60+
ext:
61+
if builtins.typeOf ext == "string" then
7162
(
72-
if builtins.hasAttr ext spicePkgs.extensions
73-
then
74-
(lib.trivial.warn
75-
''
76-
Using a string like so:
77-
programs.spicetify.enabledExtensions = [ "${ext}" ];
78-
is deprecated. Please use the following format:
79-
programs.spicetify.enabledExtensions = let
80-
spicePkgs = spicetify-nix.packages.${"$\{pkgs.system}"}.default;
81-
in
82-
with spicePkgs.extensions [ ${spicePkgs.extensions._lib.sanitizeName ext} ];
83-
''
84-
spicePkgs.extensions.${ext})
85-
else throw "Unknown extension ${ext}. Try using the lib.extension type instead of a string."
63+
if builtins.hasAttr ext spicePkgs.extensions then
64+
(lib.trivial.warn ''
65+
Using a string like so:
66+
programs.spicetify.enabledExtensions = [ "${ext}" ];
67+
is deprecated. Please use the following format:
68+
programs.spicetify.enabledExtensions = let
69+
spicePkgs = spicetify-nix.packages.${"$\{pkgs.system}"}.default;
70+
in
71+
with spicePkgs.extensions [ ${spicePkgs.extensions._lib.sanitizeName ext} ];
72+
'' spicePkgs.extensions.${ext})
73+
else
74+
throw "Unknown extension ${ext}. Try using the lib.extension type instead of a string."
8675
)
87-
else ext;
76+
else
77+
ext;
8878

89-
getApp = app:
90-
if builtins.typeOf app == "string"
91-
then
79+
getApp =
80+
app:
81+
if builtins.typeOf app == "string" then
9282
(
93-
if builtins.hasAttr app spicePkgs.apps
94-
then
95-
(
96-
lib.trivial.warn
97-
''
98-
Using a string like so:
99-
programs.spicetify.enabledCustomApps = [ "${app}" ];
100-
is deprecated. Please use the following format:
101-
programs.spicetify.enabledCustomApps = let
102-
spicePkgs = spicetify-nix.packages.${"$\{pkgs.system}"}.default;
103-
in
104-
with spicePkgs.apps [ ${app} ];
105-
''
106-
spicePkgs.apps.${app}
107-
)
108-
else throw "Unknown CustomApp ${app}. Try using the lib.app type instead of a string."
83+
if builtins.hasAttr app spicePkgs.apps then
84+
(lib.trivial.warn ''
85+
Using a string like so:
86+
programs.spicetify.enabledCustomApps = [ "${app}" ];
87+
is deprecated. Please use the following format:
88+
programs.spicetify.enabledCustomApps = let
89+
spicePkgs = spicetify-nix.packages.${"$\{pkgs.system}"}.default;
90+
in
91+
with spicePkgs.apps [ ${app} ];
92+
'' spicePkgs.apps.${app})
93+
else
94+
throw "Unknown CustomApp ${app}. Try using the lib.app type instead of a string."
10995
)
110-
else app;
96+
else
97+
app;
11198
}

0 commit comments

Comments
 (0)