mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2025-01-21 13:31:53 +01:00
the nixification continues
This commit is contained in:
parent
1eb03df288
commit
86e453ee5b
19 changed files with 207 additions and 93 deletions
|
@ -1,5 +0,0 @@
|
|||
# Alias ls to use exa
|
||||
alias ls="exa --icons --group-directories-first --classify --octal-permissions"
|
||||
alias ll="ls -l"
|
||||
alias la="ll -a"
|
||||
alias lt="ll --tree"
|
7
.config/fish/conf.d/50-eza-ls.fish.cgt
Normal file
7
.config/fish/conf.d/50-eza-ls.fish.cgt
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Alias ls to use exa
|
||||
<! local base_cmd = "exa --icons --group-directories-first --classify --octal-permissions" !>
|
||||
alias ls "<% base_cmd %>"
|
||||
alias ll "<% base_cmd %> --long"
|
||||
alias la "<% base_cmd %> --long --all"
|
||||
alias lt "<% base_cmd %> --long --tree"
|
||||
alias lta "<% base_cmd %> --long --all --tree"
|
1
cgnix/.gitignore
vendored
Normal file
1
cgnix/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
nix.lua
|
2
cgnix/README.md
Normal file
2
cgnix/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# cgnix
|
||||
This nix module acts as a shim between my confgen environment and nix. It's ultimately one single derivation which is a Lua file that declares paths into the nix store. These can then be used by confgen and thus by my scripts.
|
23
cgnix/default.nix
Normal file
23
cgnix/default.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
{
|
||||
imports = [ ./nvim-tools.nix ./tree-sitter-parsers.nix ];
|
||||
|
||||
options.cgnix.entries = lib.mkOption {
|
||||
default = { };
|
||||
};
|
||||
|
||||
config.cgnix.entries."fennel.lua" = "${pkgs.luajitPackages.fennel}/share/lua/5.1/fennel.lua";
|
||||
|
||||
config.packages.cgnix = pkgs.writeTextFile {
|
||||
name = "nix.lua";
|
||||
text = ''
|
||||
return {
|
||||
${builtins.concatStringsSep "\n" (lib.mapAttrsToList (k: v: ''["${k}"] = "${v}",'') config.cgnix.entries)}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
36
cgnix/nvim-tools.nix
Normal file
36
cgnix/nvim-tools.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ lib, pkgs, system, config, ... }:
|
||||
let
|
||||
flakePkg = ref: (builtins.getFlake ref).packages.${system}.default;
|
||||
default-packages = with pkgs; [
|
||||
# MISSING: glsl_analyzer, haxe_language_server, prosemd_lsp, racket_langserver, yamlls, zls
|
||||
# Language Servers
|
||||
(flakePkg "github:oxalica/nil")
|
||||
(pkgs.linkFarm "clangd" [{ name = "bin/clangd"; path = "${clang-tools}/bin/clangd"; }]) # only clangd
|
||||
elixir-ls
|
||||
jdt-language-server
|
||||
lua-language-server
|
||||
ocamlPackages.ocaml-lsp
|
||||
openscad-lsp
|
||||
taplo
|
||||
vscode-langservers-extracted # cssls, eslint, html, jsonls
|
||||
|
||||
# Formatters
|
||||
(pkgs.linkFarm "prettier" [{ name = "bin/prettier"; path = "${nodePackages.prettier}/bin/prettier"; }]) # needed due to symlink shenanigans
|
||||
fnlfmt
|
||||
nixpkgs-fmt
|
||||
|
||||
# Misc
|
||||
html-tidy
|
||||
shellcheck
|
||||
];
|
||||
in
|
||||
{
|
||||
options.cgnix.nvim-tools = lib.mkOption {
|
||||
default = default-packages;
|
||||
};
|
||||
|
||||
config.cgnix.entries.nvim_tools = pkgs.symlinkJoin {
|
||||
name = "nvim-tools";
|
||||
paths = config.cgnix.nvim-tools;
|
||||
};
|
||||
}
|
19
cgnix/tree-sitter-parsers.nix
Normal file
19
cgnix/tree-sitter-parsers.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
# This uses Nix to manage tree-sitter parsers for neovim, instead of nvim-treesitter's weird installer.
|
||||
{ lib, pkgs, ... }:
|
||||
let
|
||||
mapParsers = pkg:
|
||||
let
|
||||
parsername = lib.removeSuffix "-grammar" pkg.pname;
|
||||
in
|
||||
{
|
||||
# Parser
|
||||
name = "parser/${parsername}.so";
|
||||
path = "${pkg}/parser";
|
||||
};
|
||||
in
|
||||
{
|
||||
cgnix.entries.tree_sitter_parsers = pkgs.linkFarm
|
||||
"tree-sitter-parsers"
|
||||
(map mapParsers pkgs.vimPlugins.nvim-treesitter.allGrammars);
|
||||
}
|
||||
|
|
@ -24,7 +24,11 @@ cg.onDone(function(errors)
|
|||
end
|
||||
end)
|
||||
|
||||
local fennel = loadfile "/usr/share/lua/5.4/fennel.lua" ()
|
||||
local nix = (loadfile "cgnix/nix.lua" or function() return {} end)()
|
||||
|
||||
cg.opt.nix = nix
|
||||
|
||||
local fennel = (loadfile(nix["fennel.lua"] or"/usr/share/lua/5.4/fennel.lua") ())
|
||||
|
||||
-- Recursively merge 2 tables
|
||||
local function merge(a, b)
|
||||
|
|
109
flake.nix
109
flake.nix
|
@ -8,51 +8,68 @@
|
|||
{ self
|
||||
, nixpkgs
|
||||
, utils
|
||||
}: utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
flakePkg = ref: (builtins.getFlake ref).packages.${system}.default;
|
||||
in
|
||||
{
|
||||
mzteinit = pkgs.callPackage ./scripts/mzteinit/package.nix { };
|
||||
# Local user nix env
|
||||
packages.mzte-nix = pkgs.symlinkJoin {
|
||||
name = "mzte-nix";
|
||||
paths = [
|
||||
pkgs.nixpkgs-fmt
|
||||
pkgs.nix-output-monitor
|
||||
pkgs.nix-du
|
||||
(flakePkg "github:oxalica/nil")
|
||||
(flakePkg "github:nix-community/zon2nix")
|
||||
];
|
||||
};
|
||||
}: utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
common = pkgs.callPackage ./lib/common-nix { };
|
||||
flakePkg = ref: (builtins.getFlake ref).packages.${system}.default;
|
||||
|
||||
devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
# packages required to build scripts
|
||||
libGL
|
||||
libgit2
|
||||
luajit
|
||||
pkg-config
|
||||
racket
|
||||
roswell
|
||||
wayland
|
||||
wayland-protocols
|
||||
haxe
|
||||
mpv-unwrapped
|
||||
] ++
|
||||
# shorthands for setup.rkt
|
||||
builtins.map
|
||||
(cmd: pkgs.writeShellScriptBin cmd ''
|
||||
./setup.rkt ${cmd}
|
||||
'') [
|
||||
"install-scripts"
|
||||
"install-plugins"
|
||||
"install-lsps-paru"
|
||||
"setup-nvim-config"
|
||||
"setup-nix"
|
||||
"run-confgen"
|
||||
];
|
||||
};
|
||||
});
|
||||
root-mod = {
|
||||
options.packages = nixpkgs.lib.mkOption { };
|
||||
|
||||
config._module.args = {
|
||||
inherit pkgs system;
|
||||
inherit (pkgs) lib stdenv;
|
||||
};
|
||||
|
||||
# Local user nix env
|
||||
config.packages.mzte-nix = pkgs.symlinkJoin {
|
||||
name = "mzte-nix";
|
||||
paths = [
|
||||
pkgs.nix-output-monitor
|
||||
pkgs.nix-du
|
||||
(flakePkg "github:nix-community/zon2nix")
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
modopt = nixpkgs.lib.evalModules {
|
||||
modules = [ root-mod ./cgnix ] ++ common.localconf;
|
||||
specialArgs = { inherit common; };
|
||||
};
|
||||
in
|
||||
{
|
||||
mzteinit = pkgs.callPackage ./scripts/mzteinit/package.nix { };
|
||||
packages = modopt.config.packages;
|
||||
|
||||
devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
|
||||
buildInputs = with pkgs;
|
||||
[
|
||||
# packages required to build scripts
|
||||
libGL
|
||||
libgit2
|
||||
luajit
|
||||
pkg-config
|
||||
racket
|
||||
roswell
|
||||
wayland
|
||||
wayland-protocols
|
||||
haxe
|
||||
mpv-unwrapped
|
||||
] ++
|
||||
# shorthands for setup.rkt
|
||||
builtins.map
|
||||
(cmd: pkgs.writeShellScriptBin cmd ''
|
||||
./setup.rkt ${cmd}
|
||||
'') [
|
||||
"install-scripts"
|
||||
"install-plugins"
|
||||
"install-lsps-paru"
|
||||
"setup-nvim-config"
|
||||
"setup-nix"
|
||||
"run-confgen"
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
8
lib/common-nix/default.nix
Normal file
8
lib/common-nix/default.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ lib }:
|
||||
{
|
||||
localconf =
|
||||
let
|
||||
path = "${builtins.getEnv "HOME"}/.config/mzte_localconf/opts.nix";
|
||||
in
|
||||
lib.optional (builtins.pathExists path) (import path);
|
||||
}
|
|
@ -21,10 +21,19 @@ pub fn build(b: *std.Build) !void {
|
|||
|
||||
const cg_opt = try common.confgenGet(struct {
|
||||
term_font: []u8, // TODO: this being non-const is a workaround for an std bug
|
||||
nix: struct {
|
||||
tree_sitter_parsers: ?[:0]u8 = null,
|
||||
nvim_tools: ?[:0]u8 = null,
|
||||
@"fennel.lua": ?[:0]u8 = null,
|
||||
},
|
||||
}, b.allocator);
|
||||
|
||||
const opts = b.addOptions();
|
||||
opts.addOption([]const u8, "font", cg_opt.term_font);
|
||||
opts.addOption(?[:0]const u8, "tree_sitter_parsers", cg_opt.nix.tree_sitter_parsers);
|
||||
opts.addOption(?[:0]const u8, "nvim_tools", cg_opt.nix.nvim_tools);
|
||||
opts.addOption(?[:0]const u8, "fennel.lua", cg_opt.nix.@"fennel.lua");
|
||||
|
||||
lib.root_module.addImport("opts", opts.createModule());
|
||||
|
||||
lib.root_module.addImport("nvim", znvim_dep.module("nvim_c"));
|
||||
|
@ -48,6 +57,7 @@ pub fn build(b: *std.Build) !void {
|
|||
compiler.linkLibC();
|
||||
compiler.linkSystemLibrary("luajit");
|
||||
|
||||
compiler.root_module.addImport("opts", opts.createModule());
|
||||
compiler.root_module.addImport("common", b.dependency("common", .{}).module("common"));
|
||||
|
||||
compiler.root_module.unwind_tables = true;
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
(local (configs parsers ts-utils)
|
||||
(values (require :nvim-treesitter.configs)
|
||||
(local (mztenv configs parsers ts-utils)
|
||||
(values (require :mzte_nv)
|
||||
(require :nvim-treesitter.configs)
|
||||
(require :nvim-treesitter.parsers)
|
||||
(require :nvim-treesitter.ts_utils)))
|
||||
|
||||
;; Nix based parsers
|
||||
(let [path mztenv.reg.tree_sitter_parsers]
|
||||
(when path
|
||||
(vim.opt.runtimepath:append path)))
|
||||
|
||||
(var parser-config (parsers.get_parser_configs))
|
||||
|
||||
(tset parser-config :haxe {:install_info {:url "https://github.com/vantreeseba/tree-sitter-haxe"
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
(local mztenv (require :mzte_nv))
|
||||
(local cmd vim.cmd)
|
||||
|
||||
;; Update $PATH with nvim tools path
|
||||
(let [lsppath mztenv.reg.nvim_tools]
|
||||
(when lsppath
|
||||
(set vim.env.PATH (.. lsppath "/bin:" vim.env.PATH))))
|
||||
|
||||
;; CPBuf command
|
||||
(vim.api.nvim_create_user_command :CPBuf mztenv.cpbuf.copyBuf {:nargs 0})
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
const std = @import("std");
|
||||
const opts = @import("opts");
|
||||
|
||||
const ffi = @import("ffi.zig");
|
||||
const c = ffi.c;
|
||||
const ser = @import("ser.zig");
|
||||
|
@ -42,7 +44,7 @@ pub fn doCompile(path: []const u8, alloc: std.mem.Allocator) !void {
|
|||
// fennel is made to run on lua 5.4, but ends up working with LJ too
|
||||
c.lua_getfield(l, c.LUA_GLOBALSINDEX, "package");
|
||||
c.lua_getfield(l, -1, "path");
|
||||
ffi.luaPushString(l, ";" ++ "/usr/share/lua/5.4/fennel.lua");
|
||||
ffi.luaPushString(l, ";" ++ (opts.@"fennel.lua" orelse "/usr/share/lua/5.4/fennel.lua"));
|
||||
c.lua_concat(l, 2);
|
||||
c.lua_setfield(l, -2, "path");
|
||||
c.lua_pop(l, 1);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
const std = @import("std");
|
||||
const nvim = @import("nvim");
|
||||
const znvim = @import("znvim");
|
||||
const opts = @import("opts");
|
||||
|
||||
const ffi = @import("ffi.zig");
|
||||
const ser = @import("ser.zig");
|
||||
const c = ffi.c;
|
||||
|
@ -99,9 +101,17 @@ export fn luaopen_mzte_nv(l_: ?*c.lua_State) c_int {
|
|||
}
|
||||
|
||||
fn lOnInit(l: *c.lua_State) !c_int {
|
||||
_ = l;
|
||||
try @import("options.zig").initOptions();
|
||||
|
||||
c.lua_getfield(l, c.LUA_REGISTRYINDEX, reg_key);
|
||||
defer c.lua_pop(l, 1);
|
||||
inline for (.{ "tree_sitter_parsers", "nvim_tools" }) |fname| {
|
||||
if (@field(opts, fname)) |x| {
|
||||
ffi.luaPushString(l, x);
|
||||
c.lua_setfield(l, -2, fname);
|
||||
}
|
||||
}
|
||||
|
||||
std.log.info(
|
||||
"MZTE-NV v{s} Initialized on {s}",
|
||||
.{ version, nvim.longVersion },
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
const std = @import("std");
|
||||
const opts = @import("opts");
|
||||
|
||||
const ffi = @import("../ffi.zig");
|
||||
const ser = @import("../ser.zig");
|
||||
const c = ffi.c;
|
||||
|
@ -21,7 +23,7 @@ fn loadFennel(l: *c.lua_State) !void {
|
|||
|
||||
std.log.debug("loading fennel", .{});
|
||||
|
||||
if (c.luaL_loadfile(l, "/usr/share/lua/5.4/fennel.lua") != 0) {
|
||||
if (c.luaL_loadfile(l, opts.@"fennel.lua" orelse "/usr/share/lua/5.4/fennel.lua") != 0) {
|
||||
return error.FennelLoad;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
(define verb
|
||||
(command-line #:program "setup.rkt"
|
||||
#:usage-help "Sets up my dotfiles. Available verbs:"
|
||||
"install-scripts, install-plugins, install-lsps-paru, setup-nvim-config, run-confgen"
|
||||
"install-scripts, install-plugins, setup-nix, setup-nvim-config, run-confgen"
|
||||
#:once-each
|
||||
[("-o" "--bin-output") o "Output directory for executables" (output-bin-path o)]
|
||||
#:args (verb)
|
||||
|
@ -41,9 +41,6 @@
|
|||
['install-plugins
|
||||
(local-require "setup/commands/install-plugins.rkt")
|
||||
(run)]
|
||||
['install-lsps-paru
|
||||
(local-require "setup/commands/install-lsps-paru.rkt")
|
||||
(run)]
|
||||
['setup-nvim-config
|
||||
(local-require "setup/commands/setup-nvim-config.rkt")
|
||||
(run)]
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
#lang racket
|
||||
(require "../common.rkt")
|
||||
(provide run)
|
||||
|
||||
(define lsp-packages
|
||||
(list "elixir-ls-git"
|
||||
"eslint"
|
||||
"jdtls"
|
||||
"lua-language-server"
|
||||
"shellcheck"
|
||||
"shfmt"
|
||||
"taplo-cli"
|
||||
"tidy"
|
||||
"vscode-langservers-extracted"
|
||||
"yaml-language-server"
|
||||
"zls-git"))
|
||||
|
||||
(define (run)
|
||||
(apply cmd "paru" "-S" "--needed" "--noconfirm" lsp-packages)
|
||||
|
||||
;; install OCaml LSP
|
||||
(when (find-executable-path "opam")
|
||||
(cmd "opam" "install" "--yes" "ocaml-lsp-server" "ocamlformat"))
|
||||
|
||||
;; Install CommonLisp LSP
|
||||
;; Also useful for CommonLisp:
|
||||
;; - `ros install koji-kojiro/cl-repl`
|
||||
;; - `ros install fukamachi/mondo`
|
||||
(when (find-executable-path "ros")
|
||||
(cmd "ros" "install" "lem-project/lem" "cxxxr/cl-lsp"))
|
||||
null)
|
|
@ -4,4 +4,5 @@
|
|||
|
||||
(define (run)
|
||||
(define out (build-path (find-system-path 'home-dir) ".local" "mzte-nix"))
|
||||
(cmd "nix" "build" ".#mzte-nix" "--impure" "--no-write-lock-file" "--out-link" out))
|
||||
(cmd "nix" "build" ".#mzte-nix" "--impure" "--out-link" out)
|
||||
(cmd "nix" "build" ".#cgnix" "--impure" "--out-link" "cgnix/nix.lua"))
|
||||
|
|
Loading…
Add table
Reference in a new issue