Skip to content

Commit

Permalink
feat: add loads of cli tools, add logiops config for MX Vertical mous…
Browse files Browse the repository at this point in the history
…e, add config to avoid cluttering the home directory
  • Loading branch information
mrnossiom committed Dec 31, 2023
1 parent faf09ef commit 18eb32c
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 40 deletions.
2 changes: 2 additions & 0 deletions home-manager/modules/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ with lib;
init.defaultBranch = "main";
log.date = "human";

advice.addEmptyPathspec = false;

# TODO: connect to a SSOT
github.user = "mrnossiom";

Expand Down
9 changes: 5 additions & 4 deletions home-manager/modules/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ with lib;
typst-lsp.command = getExe typst-lsp;

# Default language servers
tuplo.command = getExe taplo;
gopls.command = getExe gopls;
marksman.command = getExe' marksman "marksman";
pylsp.command = getExe python311Packages.python-lsp-server;
tuplo.command = getExe taplo;
typescript-language-server.command = getExe nodePackages.typescript-language-server;
vscode-css-language-server.command = getExe' vscode-langservers-extracted "vscode-css-language-server";
vscode-html-language-server.command = getExe' vscode-langservers-extracted "vscode-html-language-server";
vscode-json-language-server.command = getExe' vscode-langservers-extracted "vscode-json-language-server";
Expand Down Expand Up @@ -121,7 +123,7 @@ with lib;
# This is also a more pure version than using `__fish_ls_*` variables
# that depends on fish internal ls wrappers and can be overriden by
# bad configuration. (e.g. NixOS `environment.shellAliases` default)
ls = "${getExe pkgs.eza} --color=auto";
ls = "${getExe pkgs.eza} --color=auto --icons=auto --hyperlink";
};

shellAbbrs = {
Expand All @@ -144,9 +146,8 @@ with lib;
mkdir = "mkdir -v";

# Listing utilities
l = "ls -GlhFa";
l = "ls -Fa";
ll = "ls -lhFa";
ls = "ls -Fa";
ld = "ls -FD";
tree = "ls -T";

Expand Down
72 changes: 66 additions & 6 deletions home-manager/profiles/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
, ...
}:

let
with lib;

let
inherit (self.inputs) agenix nix-index-database nix-colors;
inherit (self.outputs) overlays;

# Says is the config has been loaded by the NixOS HM module or is it a standalone installation.
isNixosManaged = osConfig != null;

tomlFormat = pkgs.formats.toml { };
in
{
imports = [
Expand All @@ -39,7 +41,7 @@ in
overlays = [ overlays.all ];

config = {
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
allowUnfreePredicate = pkg: builtins.elem (getName pkg) [
"authy"
"discord"
"spotify"
Expand All @@ -61,8 +63,23 @@ in

sessionVariables = {
XDG_DESKTOP_DIR = "$HOME";

# Respect XDG spec
BUN_INSTALL = "${config.xdg.dataHome}/bun";
CALCHISTFILE = "${config.xdg.cacheHome}/calc_history";
HISTFILE = "${config.xdg.dataHome}/bash_history";
RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
WAKATIME_HOME = "${config.xdg.configHome}/wakatime";
};

# Respect XDG spec
file.".npmrc".text = ''
prefix=${config.xdg.dataHome}/npm
cache=${config.xdg.cacheHome}/npm
init-module=${config.xdg.configHome}/npm/config/npm-init.js
logs-dir=${config.xdg.stateHome}/npm/logs
'';

packages = with pkgs; [
# Unfree packages
authy
Expand All @@ -71,19 +88,20 @@ in
thorium
geogebra6

spotify-tui

# GUIs
cinnamon.nemo
transmission-gtk
gnome.gnome-disk-utility
greenlight
cura
blender
element-desktop

xdg-utils
rustup
rustup # TODO: not sure to keep rustup in path
spotify-tui

# Cli tools
# CLI tools
bat
fd
delta
Expand All @@ -92,6 +110,8 @@ in
fzf
btop
tealdeer
jq
calc

imv
mpv
Expand All @@ -100,6 +120,46 @@ in
];
};

xdg.configFile."tealdeer/config.toml".source = tomlFormat.generate "tealdeer-config" {
updates.auto_update = true;
};

programs.broot.enable = true;

programs.yazi = {
enable = true;

enableBashIntegration = true;
enableFishIntegration = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};

programs.go = {
enable = true;
goPath = ".local/share/go";
};

home.file.".cargo/config.toml".source = tomlFormat.generate "cargo-config" {
build.rustc-wrapper = getExe' pkgs.sccache "sccache";

source = {
local-mirror.registry = "sparse+http://local.crates.io:8080/index/";
# crates-io.replace-with = "local-mirror";
};

target = {
x86_64-unknown-linux-gnu = {
linker = getExe pkgs.llvmPackages.clang;
rustflags = [ "-Clink-arg=--ld-path=${getExe pkgs.mold}" "-Ctarget-cpu=native" ];
};
x86_64-apple-darwin.rustflags = [ "-Clink-arg=-fuse-ld=${getExe' pkgs.llvmPackages.lld "lld"}" "-Ctarget-cpu=native" ];
aarch64-apple-darwin.rustflags = [ "-Clink-arg=-fuse-ld=${getExe' pkgs.llvmPackages.lld "lld"}" "-Ctarget-cpu=native" ];
};

unstable.gc = true;
};

xdg.mimeApps = {
enable = true;
associations.added = {
Expand Down
54 changes: 28 additions & 26 deletions modules/home-manager/xcompose.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,36 @@ in
};
};

config = mkIf cfg.enable {
home.file.".XCompose".text =
let

comboListToString = foldl (acc: val: acc + "<${val}> ") "";
sanitizeComboResult = escape [ ''"'' ];

comboSetToList = ip: flatten (mapAttrsToList
(name: value:
if isAttrs value then
let vs = comboSetToList value;
in
map ({ combo, value }: { combo = [ name ] ++ combo; inherit value; }) vs
else if isString value then
{ combo = [ name ]; inherit value; }
else throw "combo value must be a string"
)
ip);
complexListToSimple = map ({ combo, value }: { combo = comboListToString combo; value = sanitizeComboResult value; });
toComposeFile = foldl (acc: val: acc + "${val.combo}: \"${val.value}\"\n") "";

processComposeSet = set: toComposeFile (complexListToSimple (comboSetToList set));

in
''
config =
let
comboListToString = foldl (acc: val: acc + "<${val}> ") "";
sanitizeComboResult = escape [ ''"'' ];

comboSetToList = ip: flatten (mapAttrsToList
(name: value:
if isAttrs value then
let vs = comboSetToList value;
in
map ({ combo, value }: { combo = [ name ] ++ combo; inherit value; }) vs
else if isString value then
{ combo = [ name ]; inherit value; }
else throw "combo value must be a string"
)
ip);
complexListToSimple = map ({ combo, value }: { combo = comboListToString combo; value = sanitizeComboResult value; });
toComposeFile = foldl (acc: val: acc + "${val.combo}: \"${val.value}\"\n") "";

processComposeSet = set: toComposeFile (complexListToSimple (comboSetToList set));

composeFile = pkgs.writeText "XCompose" ''
${optionalString cfg.includeLocaleCompose "include \"%L\""}
${processComposeSet cfg.sequences}
'';
};
in
mkIf cfg.enable {
# I use an env var to avoid cluttering my home directory
home.sessionVariables.XCOMPOSEFILE = composeFile;
# home.file.".XCompose".text = composeContent;
};
}
4 changes: 3 additions & 1 deletion modules/nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{ }
{
logiops = ./logiops.nix;
}
73 changes: 73 additions & 0 deletions modules/nixos/logiops.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{ config, lib, pkgs, ... }:

with lib;

let
cfg = config.services.logiops;
renderedConfig = (pkgs.formats.libconfig { }).generate "logid.cfg" cfg.settings;
in
{
options.services.logiops = {
enable = mkEnableOption (mdDoc "Logiops HID++ configuration");

package = mkPackageOption pkgs "logiops" { };

settings = mkOption {
type = (pkgs.formats.libconfig { }).type;
default = { };
example = {
devices = [{
name = "Wireless Mouse MX Master 3";

smartshift = {
on = true;
threshold = 20;
};

hiresscroll = {
hires = true;
invert = false;
target = false;
};

dpi = 1500;

buttons = [
{
cid = "0x53";
action = {
type = "Keypress";
keys = [ "KEY_FORWARD" ];
};
}
{
cid = "0x56";
action = {
type = "Keypress";
keys = [ "KEY_BACK" ];
};
}
];
}];
};
description = mdDoc ''
Logid configuration. Refer to
[the `logiops` wiki](https://github.com/PixlOne/logiops/wiki/Configuration)
for details on supported values.
'';
};
};

config = mkIf cfg.enable {
services.udev.packages = [ pkgs.logitech-udev-rules ];
environment.etc."logid.cfg".source = renderedConfig;

systemd.packages = [ cfg.package ];
systemd.services.logid = {
wantedBy = [ "multi-user.target" ];
restartTriggers = [ renderedConfig ];
};
};

meta.maintainers = with maintainers; [ ckie ];
}
Loading

0 comments on commit 18eb32c

Please sign in to comment.