nixbook: git config, nixd, format

This commit is contained in:
tristan 2024-10-23 22:53:02 +01:00
parent 7322eaeb6f
commit 3bae7dc77c
6 changed files with 91 additions and 66 deletions

View file

@ -5,6 +5,7 @@
graph = "log --oneline --all --graph";
amend = "commit --amend --no-edit";
sdiff = "diff --staged";
fpush = "push --force-with-lease";
t = "tag --annotate";
bclone = "!sh ${pkgs.writeShellScriptBin "bare-clone" ''
url=$1

View file

@ -3,12 +3,12 @@
pkgs,
lib,
...
}: {
} @ input: {
programs.nixvim =
{
enable = true;
}
// (import ../../../lib/nixvim.nix {inherit pkgs;});
// (import ../../../lib/nixvim.nix input);
programs.vscode = {
extensions = [pkgs.vscode-extensions.asvetliakov.vscode-neovim];

View file

@ -15,6 +15,11 @@ in {
email = "tristan.beedell@cryoserver.com";
terminal = false;
};
programs.git.extraConfig = {
"includeIf \"gitdir:~/Documents/personal/\"" = {
path = "~/Documents/personal/.gitconfig";
};
};
home.packages = [
pkgs.thunderbird
@ -31,17 +36,19 @@ in {
desktopName = "Microsoft Teams";
})
pkgs.devcontainer
(pkgs.writeShellScriptBin "devcontainer-open" (let
jq = "${pkgs.jq}/bin/jq";
devcontainer = "${pkgs.devcontainer}/bin/devcontainer";
in ''
res=$(${devcontainer} up --workspace-folder .)
outcome=$(echo $res | ${jq} -r '.outcome')
[[ $outcome = "success" ]] || exit 1
containerId=$(echo $res | ${jq} -r '.containerId')
remoteWorkspaceFolder=$(echo $res | ${jq} -r '.remoteWorkspaceFolder')
docker exec -it --workdir=$remoteWorkspaceFolder $containerId bash
''))
(pkgs.writeShellScriptBin "devcontainer-open" (
let
jq = "${pkgs.jq}/bin/jq";
devcontainer = "${pkgs.devcontainer}/bin/devcontainer";
in ''
res=$(${devcontainer} up --workspace-folder .)
outcome=$(echo $res | ${jq} -r '.outcome')
[[ $outcome = "success" ]] || exit 1
containerId=$(echo $res | ${jq} -r '.containerId')
remoteWorkspaceFolder=$(echo $res | ${jq} -r '.remoteWorkspaceFolder')
docker exec -it --workdir=$remoteWorkspaceFolder $containerId bash
''
))
];
home.sessionVariables = {

View file

@ -28,6 +28,7 @@
playerctl
quickemu
devenv
logseq
];
services.udiskie = {
@ -37,7 +38,7 @@
programs.rbw.settings.pinentry = pkgs.pinentry-gnome3;
# https://docs.pipewire.org/page_module_raop_discover.html
# https://docs.pipewire.org/page_module_raop_discover.html
xdg.configFile."pipewire/pipewire.conf.d/raop-discover.conf".text = ''
context.modules = [
{
@ -47,28 +48,28 @@
]
'';
xdg.configFile."pipewire/pipewire.conf.d/raop-sink.conf".text = ''
context.modules = [
{ name = libpipewire-module-raop-sink
args = {
# Set the remote address to tunnel to
raop.ip = "127.0.0.1"
raop.port = 8190
raop.name = "my-raop-device"
raop.hostname = "My Service"
#raop.transport = "udp"
raop.encryption.type = "RSA"
#raop.audio.codec = "PCM"
#raop.password = "****"
#audio.format = "S16"
#audio.rate = 44100
#audio.channels = 2
#audio.position = [ FL FR ]
stream.props = {
# extra sink properties
}
}
}
]
context.modules = [
{ name = libpipewire-module-raop-sink
args = {
# Set the remote address to tunnel to
raop.ip = "127.0.0.1"
raop.port = 8190
raop.name = "my-raop-device"
raop.hostname = "My Service"
#raop.transport = "udp"
raop.encryption.type = "RSA"
#raop.audio.codec = "PCM"
#raop.password = "****"
#audio.format = "S16"
#audio.rate = 44100
#audio.channels = 2
#audio.position = [ FL FR ]
stream.props = {
# extra sink properties
}
}
}
]
'';
services.gnome-keyring.enable = true;

View file

@ -1,9 +1,14 @@
{pkgs, ...}: let
{
pkgs,
lib,
...
}: let
lua = cmd: {__raw = cmd;};
luaFunc = cmd: lua ''
function ()
${cmd}
end'';
luaFunc = cmd:
lua ''
function ()
${cmd}
end'';
in {
globals = {
mapleader = " ";
@ -28,6 +33,8 @@ in {
"extends:>"
"precedes:<"
];
foldlevel = 2;
};
extraPlugins = [(pkgs.vimPlugins.actions-preview-nvim)];
extraConfigLua = ''
@ -204,30 +211,32 @@ in {
}
];
autoCmd = [{
event = "BufWritePre";
pattern = "*.go";
# https://github.com/golang/tools/blob/master/gopls/doc/vim.md#imports-and-formatting
callback = luaFunc ''
local params = vim.lsp.util.make_range_params()
params.context = {only = {"source.organizeImports"}}
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
-- machine and codebase, you may want longer. Add an additional
-- argument after params if you find that you have to write the file
-- twice for changes to be saved.
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
vim.lsp.util.apply_workspace_edit(r.edit, enc)
autoCmd = [
{
event = "BufWritePre";
pattern = "*";
# https://github.com/golang/tools/blob/master/gopls/doc/vim.md#imports-and-formatting
callback = luaFunc ''
local params = vim.lsp.util.make_range_params()
params.context = {only = {"source.organizeImports"}}
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
-- machine and codebase, you may want longer. Add an additional
-- argument after params if you find that you have to write the file
-- twice for changes to be saved.
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
vim.lsp.util.apply_workspace_edit(r.edit, enc)
end
end
end
end
vim.lsp.buf.format({async = false})
'';
}];
vim.lsp.buf.format({async = false})
'';
}
];
plugins = {
bufferline.enable = true;
@ -261,7 +270,15 @@ in {
enable = true;
servers = {
ts-ls.enable = true;
nil-ls.enable = true;
nixd = {
enable = true;
settings = {
nixpkgs.expr = ''import <nixpkgs> {}'';
options.zenix.expr = ''(builtins.getFlake "git+https://git.tristans.cloud/tristan/nix").nixosConfigurations.zenix.options'';
options.alpine.expr = ''(builtins.getFlake "git+https://git.tristans.cloud/tristan/nix").nixosConfigurations.alpine.options'';
formatting.command = [(lib.getExe pkgs.alejandra)];
};
};
yamlls.enable = true;
gopls.enable = true;
};

View file

@ -1,7 +1,6 @@
{config, ...}: let
user = config.user;
in
{
in {
users.users.${user}.extraGroups = ["libvirtd" "kvm"];
virtualisation.libvirtd = {
enable = true;