feat(code)!: improve interface

nixos
Moritz Böhme 2023-05-27 12:00:08 +02:00
parent a6e8356cb5
commit d2111cc645
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
1 changed files with 51 additions and 15 deletions

View File

@ -9,21 +9,57 @@ let
cfg = config.my.programs.code;
in
{
options.my.programs.code.enable = mkEnableOption "code";
config = mkIf cfg.enable {
home-manager.users.moritz = {
programs.vscode = {
enable = true;
package = pkgs.vscode-fhsWithPackages (ps: with ps; [ git ]);
extensions = with pkgs.vscode-extensions; [
options.my.programs.code = {
enable = mkEnableOption "code";
package = mkOption {
type = types.package;
default = pkgs.vscode;
};
extensions = mkOption {
type = types.listOf types.package;
default = with pkgs.vscode-extensions; [
bbenoist.nix
dracula-theme.theme-dracula
esbenp.prettier-vscode
pkief.material-icon-theme
vscodevim.vim
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "copilot-nightly";
publisher = "GitHub";
version = "1.86.118";
sha256 = "04nspnmd5cfnv3m9igww6h6la6pvhdqzqmdnbm1znapxqiw2m927";
}
{
name = "copilot-chat";
publisher = "GitHub";
version = "0.1.2023052602";
sha256 = "0anlzzs4g7c9mmw7yxy5bgjcs0niwa3bswgvhwspf5fh8bbq5n44";
}
];
};
wayland = mkOption {
type = types.bool;
default = true;
};
};
config = mkIf cfg.enable {
environment.systemPackages =
let
withExtensions = pkgs.vscode-with-extensions.override {
vscode = cfg.package;
vscodeExtensions = cfg.extensions;
};
maybeExtensions = if cfg.extensions == [ ] then cfg.package else withExtensions;
withWayland = pkgs.symlinkJoin {
name = "${maybeExtensions.name}-wayland";
paths = [ maybeExtensions ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/code* \
--set NIXOS_OZONE_WL 1
'';
};
final = if cfg.wayland then withWayland else maybeExtensions;
in
[ final ];
};
}