remove vscode-mod
This commit is contained in:
parent
174172e847
commit
38ffaa0e29
|
@ -34,8 +34,6 @@ in {
|
|||
./secrets.nix
|
||||
]);
|
||||
|
||||
# TODO: environment.noXlibs = true;
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(_final: prev: {
|
||||
# So we don't need to build all Vault
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
defaultModules = [
|
||||
tree.profiles.home-manager.base
|
||||
|
||||
tree.modules.home.vscode-mod-module
|
||||
];
|
||||
|
||||
pkgsFor = system:
|
||||
|
|
|
@ -1,238 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.programs.vscode-mod;
|
||||
|
||||
vscodePname = cfg.package.pname;
|
||||
|
||||
jsonFormat = pkgs.formats.json {};
|
||||
|
||||
configDir =
|
||||
{
|
||||
"vscode" = "Code";
|
||||
"vscode-insiders" = "Code - Insiders";
|
||||
"vscodium" = "VSCodium";
|
||||
}
|
||||
.${vscodePname};
|
||||
|
||||
extensionDir =
|
||||
{
|
||||
"vscode" = "vscode";
|
||||
"vscode-insiders" = "vscode-insiders";
|
||||
"vscodium" = "vscode-oss";
|
||||
}
|
||||
.${vscodePname};
|
||||
|
||||
userDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin
|
||||
then "Library/Application Support/${configDir}/User"
|
||||
else "${config.xdg.configHome}/${configDir}/User";
|
||||
|
||||
configFilePath = "${userDir}/settings.json";
|
||||
tasksFilePath = "${userDir}/tasks.json";
|
||||
keybindingsFilePath = "${userDir}/keybindings.json";
|
||||
|
||||
# TODO: On Darwin where are the extensions?
|
||||
extensionPath = ".${extensionDir}/extensions";
|
||||
|
||||
mergedUserSettings =
|
||||
cfg.userSettings
|
||||
// optionalAttrs (!cfg.enableUpdateCheck) {"update.mode" = "none";}
|
||||
// optionalAttrs (!cfg.enableExtensionUpdateCheck) {
|
||||
"extensions.autoCheckUpdates" = false;
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
programs.vscode-mod = {
|
||||
enable = mkEnableOption "Visual Studio Code";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.vscode;
|
||||
example = literalExpression "pkgs.vscodium";
|
||||
description = ''
|
||||
Version of Visual Studio Code to install.
|
||||
'';
|
||||
};
|
||||
|
||||
enableUpdateCheck = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable update checks/notifications.
|
||||
'';
|
||||
};
|
||||
|
||||
enableExtensionUpdateCheck = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable update notifications for extensions.
|
||||
'';
|
||||
};
|
||||
|
||||
userSettings = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = {};
|
||||
example = literalExpression ''
|
||||
{
|
||||
"files.autoSave" = "off";
|
||||
"[nix]"."editor.tabSize" = 2;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to Visual Studio Code's
|
||||
<filename>settings.json</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
userTasks = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = {};
|
||||
example = literalExpression ''
|
||||
{
|
||||
version = "2.0.0";
|
||||
tasks = [
|
||||
{
|
||||
type = "shell";
|
||||
label = "Hello task";
|
||||
command = "hello";
|
||||
}
|
||||
];
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to Visual Studio Code's
|
||||
<filename>tasks.json</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
keybindings = mkOption {
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
key = mkOption {
|
||||
type = types.str;
|
||||
example = "ctrl+c";
|
||||
description = "The key or key-combination to bind.";
|
||||
};
|
||||
|
||||
command = mkOption {
|
||||
type = types.str;
|
||||
example = "editor.action.clipboardCopyAction";
|
||||
description = "The VS Code command to execute.";
|
||||
};
|
||||
|
||||
when = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "textInputFocus";
|
||||
description = "Optional context filter.";
|
||||
};
|
||||
|
||||
# https://code.visualstudio.com/docs/getstarted/keybindings#_command-arguments
|
||||
args = mkOption {
|
||||
type = types.nullOr jsonFormat.type;
|
||||
default = null;
|
||||
example = {direction = "up";};
|
||||
description = "Optional arguments for a command.";
|
||||
};
|
||||
};
|
||||
});
|
||||
default = [];
|
||||
example = literalExpression ''
|
||||
[
|
||||
{
|
||||
key = "ctrl+c";
|
||||
command = "editor.action.clipboardCopyAction";
|
||||
when = "textInputFocus";
|
||||
}
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
Keybindings written to Visual Studio Code's
|
||||
<filename>keybindings.json</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
example = literalExpression "[ pkgs.vscode-extensions.bbenoist.nix ]";
|
||||
description = ''
|
||||
The extensions Visual Studio Code should be started with.
|
||||
'';
|
||||
};
|
||||
|
||||
mutableExtensionsDir = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description = ''
|
||||
Whether extensions can be installed or updated manually
|
||||
or by Visual Studio Code.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [cfg.package];
|
||||
|
||||
# make config changeable
|
||||
home = {
|
||||
activation = {
|
||||
vscode-mod-copy = hm.dag.entryAfter ["writeBoundary"] ''
|
||||
$DRY_RUN_CMD cat "${configFilePath}.source" > "${configFilePath}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
home.file = mkMerge [
|
||||
(mkIf (mergedUserSettings != {}) {
|
||||
# Don't install settings to actual config file path
|
||||
# instead install to ${configFilePath}.source
|
||||
"${configFilePath}.source".source =
|
||||
jsonFormat.generate "vscode-user-settings" mergedUserSettings;
|
||||
})
|
||||
|
||||
(mkIf (cfg.userTasks != {}) {
|
||||
"${tasksFilePath}".source =
|
||||
jsonFormat.generate "vscode-user-tasks" cfg.userTasks;
|
||||
})
|
||||
(mkIf (cfg.keybindings != [])
|
||||
(let
|
||||
dropNullFields = filterAttrs (_: v: v != null);
|
||||
in {
|
||||
"${keybindingsFilePath}".source =
|
||||
jsonFormat.generate "vscode-keybindings"
|
||||
(map dropNullFields cfg.keybindings);
|
||||
}))
|
||||
(mkIf (cfg.extensions != []) (let
|
||||
subDir = "share/vscode/extensions";
|
||||
|
||||
# Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2
|
||||
toPaths = ext:
|
||||
map (k: {"${extensionPath}/${k}".source = "${ext}/${subDir}/${k}";})
|
||||
(
|
||||
if ext ? vscodeExtUniqueId
|
||||
then [ext.vscodeExtUniqueId]
|
||||
else builtins.attrNames (builtins.readDir (ext + "/${subDir}"))
|
||||
);
|
||||
in
|
||||
if cfg.mutableExtensionsDir
|
||||
then mkMerge (concatMap toPaths cfg.extensions)
|
||||
else {
|
||||
"${extensionPath}".source = let
|
||||
combinedExtensionsDrv = pkgs.buildEnv {
|
||||
name = "vscode-extensions";
|
||||
paths = cfg.extensions;
|
||||
};
|
||||
in "${combinedExtensionsDrv}/${subDir}";
|
||||
}))
|
||||
];
|
||||
};
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
home.sessionVariables = {
|
||||
DONT_PROMPT_WSL_INSTALL = 1;
|
||||
};
|
||||
programs.vscode-mod = {
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
userSettings = {
|
||||
"terminal.integrated.shellIntegration.enabled" = false;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [go gopls go-outline gotools];
|
||||
programs.vscode-mod.extensions = with pkgs; [vscode-extensions.golang.go];
|
||||
programs.vscode.extensions = with pkgs; [vscode-extensions.golang.go];
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [alejandra deadnix statix];
|
||||
|
||||
programs.vscode-mod.extensions = with pkgs; [
|
||||
programs.vscode.extensions = with pkgs; [
|
||||
vscode-extensions.bbenoist.nix
|
||||
vscode-extensions.kamadorueda.alejandra
|
||||
];
|
||||
|
||||
programs.vscode-mod.userSettings."[nix]" = {
|
||||
programs.vscode.userSettings."[nix]" = {
|
||||
"editor.defaultFormatter" = "kamadorueda.alejandra";
|
||||
"editor.formatOnSave" = true;
|
||||
};
|
||||
programs.vscode-mod.userSettings = {
|
||||
programs.vscode.userSettings = {
|
||||
"alejandra.program" = "alejandra";
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{pkgs, ...}: {
|
||||
programs.vscode-mod.extensions = with pkgs; [vscode-extensions.rust-lang.rust-analyzer];
|
||||
programs.vscode.extensions = with pkgs; [vscode-extensions.rust-lang.rust-analyzer];
|
||||
home.packages = with pkgs; [rustc cargo clippy rust-analyzer rustfmt];
|
||||
home.sessionVariables = {RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;};
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ in {
|
|||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
sharedModules = with tree; [modules.home.vscode-mod-module];
|
||||
sharedModules = with tree; [];
|
||||
};
|
||||
systemd.tmpfiles.rules = mkIf config.boot.isContainer (flatten (forEach (builtins.attrNames config.home-manager.users) (user: [
|
||||
"d /nix/var/nix/profiles/per-user/${user} - ${config.users.users."${user}".group} - - -"
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd $SCRIPT_DIR
|
||||
cd $(git rev-parse --show-toplevel)
|
||||
|
||||
DEFAULT_HOST="root@vault.servers.genderfucked.monster"
|
||||
TARGET_HOST=${HOST:-${DEFAULT_HOST}}
|
||||
nixos-rebuild switch --flake .#vault --target-host "$TARGET_HOST" --no-build-nix --fast --use-substitutes -s "$@"
|
Loading…
Reference in a new issue