feat(code)!: improve interface

This commit is contained in:
Moritz Böhme 2023-05-27 12:00:08 +02:00
parent a6e8356cb5
commit d2111cc645
Signed by: moritz
GPG key ID: 970C6E89EB0547A9

View file

@ -9,21 +9,57 @@ let
cfg = config.my.programs.code; cfg = config.my.programs.code;
in in
{ {
options.my.programs.code.enable = mkEnableOption "code"; options.my.programs.code = {
enable = mkEnableOption "code";
config = mkIf cfg.enable { package = mkOption {
home-manager.users.moritz = { type = types.package;
programs.vscode = { default = pkgs.vscode;
enable = true; };
package = pkgs.vscode-fhsWithPackages (ps: with ps; [ git ]); extensions = mkOption {
extensions = with pkgs.vscode-extensions; [ type = types.listOf types.package;
bbenoist.nix default = with pkgs.vscode-extensions; [
dracula-theme.theme-dracula bbenoist.nix
esbenp.prettier-vscode vscodevim.vim
pkief.material-icon-theme ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
vscodevim.vim {
]; 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 ];
};
} }