Skip to content

Commit

Permalink
build(nix): improve builer, add basic ci expression
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston committed Dec 14, 2023
1 parent 2f6e2b4 commit bafe788
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 38 deletions.
28 changes: 28 additions & 0 deletions nix/ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{pkgs ? import <nixpkgs> {}}: let
catppuccin-vsc = pkgs.callPackage ./. {};
in {
default = catppuccin-vsc;

customized = catppuccin-vsc.override {
accent = "pink";
boldKeywords = false;
italicComments = false;
italicKeywords = false;
colorOverrides = {
mocha = rec {
base = "#000000";
mantle = base;
crust = base;
};
};
customUIColors = {
all = {
"statusBar.foreground" = "accent";
"statusBar.noFolderForeground" = "accent";
};
};
workbenchMode = "minimal";
bracketMode = "monochromatic";
extraBordersEnabled = true;
};
}
57 changes: 19 additions & 38 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
} @ inputs: let
inherit (pkgs) lib;

packageJSON = builtins.fromJSON (builtins.readFile ../package.json);
packageJSON = builtins.fromJSON (builtins.readFile ../packages/catppuccin-vsc/package.json);
properties = packageJSON.contributes.configuration.properties;
validAccents = properties."catppuccin.accentColor".enum;
validWorkbenchModes = properties."catppuccin.workbenchMode".enum;
Expand All @@ -28,64 +28,45 @@
builder = pkgs.callPackage ./yarn-project.nix {} {
inherit src;
overrideAttrs = {
name = "${pname}-builder";
pname = "${pname}-builder";

buildPhase = ''
runHook preBuild
yarn build
yarn core:build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out
cp -r dist/* $out
cd packages/catppuccin-vsc
cp -rL LICENSE README.md package.json dist/ themes/ $out/
runHook postInstall
'';
};
};
in
(lib.throwIfNot (accentColor == null) "${pname}: deprecated option 'accentColor' is no longer supported, please use 'accent' instead.")
(lib.checkListOfEnum "${pname}: accent" validAccents [accent])
(lib.checkListOfEnum "${pname}: workbenchMode" validWorkbenchModes [workbenchMode])
(lib.checkListOfEnum "${pname}: bracketMode" validBracketModes [bracketMode])
pkgs.vscode-utils.buildVscodeExtension rec {
inherit name;
src = builder.outPath;
vscodeExtPublisher = "catppuccin";
vscodeExtName = name;
vscodeExtUniqueId = "${vscodeExtPublisher}.${vscodeExtName}";

extension = pkgs.stdenvNoCC.mkDerivation {
inherit name version pname src;
buildInputs = [pkgs.nodejs pkgs.vsce];

# check in the ./themes/.flag so it doesn't prompt for initial rebuilds
patchPhase = ''
runHook prePatch
printf "\n!themes/.flag\n" >> .vscodeignore
runHook postPatch
'';
buildInputs = [pkgs.nodejs];

env.CATPPUCCIN_OPTIONS = builtins.toJSON options;

# we're checking in the ./themes/.flag file so it doesn't prompt for initial rebuilds
buildPhase = ''
runHook preBuild
mkdir -p themes dist
cp -r ${builder}/* dist/
touch ./themes/.flag
node dist/hooks/generateThemes.js
vsce package --no-dependencies
touch ./themes/.flag
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out
# rename the file extension to zip for the buildVSCodeMarketplaceExtension builder
mv catppuccin-vsc-*.vsix $out/catppuccin-vsc.zip
runHook postInstall
'';
};
in
(lib.throwIfNot (accentColor == null) "${pname}: deprecated option 'accentColor' is no longer supported, please use 'accent' instead.")
(lib.checkListOfEnum "${pname}: accent" validAccents [accent])
(lib.checkListOfEnum "${pname}: workbenchMode" validWorkbenchModes [workbenchMode])
(lib.checkListOfEnum "${pname}: bracketMode" validBracketModes [bracketMode])
pkgs.vscode-utils.buildVscodeMarketplaceExtension {
vsix = "${extension.outPath}/catppuccin-vsc.zip";
mktplcRef = {
# lowercase since it is used in the pname
publisher = "catppuccin";
inherit name version;
};
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"tsx": "^4.6.2",
"typescript": "^5.3.2"
},
"dependenciesMeta": {
"keytar": {
"built": false
}
},
"lint-staged": {
"*.ts": "eslint --cache --fix",
"*.{ts,json,md}": "prettier --write"
Expand Down
3 changes: 3 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,9 @@ __metadata:
tsup: "npm:^8.0.1"
tsx: "npm:^4.6.2"
typescript: "npm:^5.3.2"
dependenciesMeta:
keytar:
built: false
languageName: unknown
linkType: soft

Expand Down

0 comments on commit bafe788

Please sign in to comment.