-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(nix): improve nix build, step 1
refs: #218
- Loading branch information
1 parent
235693b
commit 5c30371
Showing
9 changed files
with
100 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
use nix | ||
use nix ./nix/shell.nix | ||
layout node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
pkgs ? import <nixpkgs> {}, | ||
accentColor ? "mauve", | ||
boldKeywords ? true, | ||
italicComments ? true, | ||
italicKeywords ? true, | ||
extraBordersEnabled ? false, | ||
workbenchMode ? "default", | ||
bracketMode ? "rainbow", | ||
colorOverrides ? {}, | ||
customUIColors ? {}, | ||
} @ inputs: let | ||
inherit (pkgs) lib; | ||
|
||
packageJSON = builtins.fromJSON (builtins.readFile ../package.json); | ||
properties = (builtins.head packageJSON.contributes.configuration).properties; | ||
validAccents = properties."catppuccin.accentColor".enum; | ||
validWorkbenchModes = properties."catppuccin.workbenchMode".enum; | ||
validBracketModes = properties."catppuccin.bracketMode".enum; | ||
|
||
inherit (packageJSON) name version; | ||
pname = "${name}-${version}"; | ||
|
||
options = builtins.removeAttrs inputs ["pkgs"]; | ||
src = pkgs.nix-gitignore.gitignoreSource [] ../.; | ||
builder = pkgs.callPackage ./yarn-project.nix {} { | ||
inherit src; | ||
overrideAttrs = { | ||
pname = "${pname}-build"; | ||
buildPhase = '' | ||
runHook preBuild | ||
yarn compile | ||
runHook postBuild | ||
''; | ||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out | ||
cp -r dist/* $out | ||
runHook postInstall | ||
''; | ||
}; | ||
}; | ||
extension = pkgs.stdenvNoCC.mkDerivation { | ||
inherit name version pname src; | ||
|
||
buildInputs = [pkgs.nodejs pkgs.vsce pkgs.yarn]; | ||
|
||
# check in the ./themes/.flag so it doesn't prompt for initial rebuilds | ||
patchPhase = '' | ||
runHook prePatch | ||
printf "\n!themes/.flag\n" >> .vscodeignore | ||
runHook postPatch | ||
''; | ||
buildPhase = '' | ||
runHook preBuild | ||
mkdir -p themes dist | ||
cp -r ${builder}/* dist/ | ||
touch ./themes/.flag | ||
node dist/hooks/generateThemes.js '${builtins.toJSON options}' | ||
vsce package --allow-star-activation --yarn | ||
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.checkListOfEnum "${pname}: accent" validAccents [accentColor]) | ||
(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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,7 @@ in | |
buildInputs = [ | ||
nodejs | ||
(pkgs.yarn.override {inherit nodejs;}) | ||
pkgs.alejandra | ||
pkgs.nil | ||
]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
const dev = process.env.NODE_ENV === "development"; | ||
|
||
export default defineConfig({ | ||
entry: ["src/browser.ts", "src/main.ts"], | ||
entry: ["src/browser.ts", "src/main.ts", "src/hooks/generateThemes.ts"], | ||
external: ["vscode"], | ||
sourcemap: true, | ||
sourcemap: dev, | ||
minify: !dev, | ||
target: "node16", | ||
clean: true, | ||
splitting: true, | ||
}); |