refactor(treewide): clean-up, flatten, rework module system

This commit is contained in:
ooks-io 2024-06-05 22:56:07 +12:00
parent 4ddf9d2b35
commit 5590c8a951
58 changed files with 397 additions and 635 deletions

View file

@ -1,18 +1,21 @@
{ inputs, config, pkgs, lib, ... }:
let
cfg = config.ooknet.console.editor.helix;
inherit (config) colorscheme;
in
{
let
inherit (config) colorscheme;
inherit (lib) mkIf;
cfg = config.ooknet.editor.helix;
console = config.ooknet.console;
in
{
imports = [
./languages.nix
];
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.editor == "helix") {
programs.helix = {
enable = true;
defaultEditor = lib.mkIf cfg.default true;
defaultEditor = mkIf (console.editor == "helix") true;
package = inputs.helix.packages.${pkgs.system}.default.overrideAttrs (old: {
makeWrapperArgs = with pkgs;
old.makeWrapperArgs

View file

@ -1,11 +1,13 @@
{ pkgs, lib, config, ... }:
let
cfg = config.ooknet.console.editor.helix;
inherit (lib) mkIf getExe;
cfg = config.ooknet.editor.helix;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.editor == "helix") {
programs.helix.languages = {
language = let
deno = lang: {
@ -89,12 +91,12 @@ in
};
nil = {
command = lib.getExe pkgs.nil;
config.nil.formatting.command = ["${lib.getExe pkgs.alejandra}" "-q"];
command = getExe pkgs.nil;
config.nil.formatting.command = ["${getExe pkgs.alejandra}" "-q"];
};
dprint = {
command = lib.getExe pkgs.dprint;
command = getExe pkgs.dprint;
args = ["lsp"];
};

View file

@ -2,7 +2,9 @@
let
inherit (config.colorscheme) palette;
cfg = config.ooknet.console.editor.nvim;
inherit (lib) mkIf;
cfg = config.ooknet.editor.nvim;
console = config.ooknet.console;
in
{
@ -13,7 +15,7 @@ in
./plugins
];
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.editor == "nvim") {
programs.neovim = {
viAlias = true;
vimAlias = true;

View file

@ -1,11 +1,13 @@
{ config, lib, ... }:
let
cfg = config.ooknet.console.editor.nvim;
inherit (lib) mkIf mapAttrsToList;
cfg = config.ooknet.editor.nvim;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.editor == "nvim") {
programs.nixvim = {
globals = {
mapleader = " ";
@ -14,7 +16,7 @@ in
keymaps = let
normal =
lib.mapAttrsToList
mapAttrsToList
(key: action: {
mode = "n";
inherit action key;
@ -25,7 +27,7 @@ in
"Y" = "$y";
};
visual =
lib.mapAttrsToList
mapAttrsToList
(key: action: {
mode = "v";
inherit action key;

View file

@ -1,28 +1,7 @@
{ lib, ... }:
{
imports = [
./indent.nix
./telescope.nix
./lualine.nix
];
options.ooknet.console.editor.nvim.plugins = {
indentBlankline = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable indent-blankline nvim plugin module";
};
lualine = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable lualine nvim plugin module";
};
telescope = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable telescope nvim plugin module";
};
};
}

View file

@ -1,11 +1,13 @@
{ config, lib, ... }:
let
cfg = config.ooknet.console.editor.nvim.plugins;
inherit (lib) mkIf;
cfg = config.ooknet.editor.nvim;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.indentBlankline {
config = mkIf (cfg.enable || console.editor == "nvim") {
programs.nixvim.plugins.indent-blankline = {
enable = true;
};

View file

@ -1,11 +1,13 @@
{ config, lib, ... }:
let
cfg = config.ooknet.console.editor.nvim.plugins;
inherit (lib) mkIf;
cfg = config.ooknet.editor.nvim;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.lualine {
config = mkIf (cfg.enable || console.editor == "nvim") {
programs.nixvim.plugins.lualine = {
enable = true;
theme = "base16";

View file

@ -1,11 +1,13 @@
{ config, lib, ... }:
let
cfg = config.ooknet.console.editor.nvim.plugins;
inherit (lib) mkIf;
cfg = config.ooknet.editor.nvim;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.telescope {
config = mkIf (cfg.enable || console.editor == "nvim") {
programs.nixvim = {
plugins.telescope = {
enable = true;

View file

@ -2,11 +2,13 @@
let
inherit (config.colorscheme) palette;
cfg = config.ooknet.console.editor.nvim;
inherit (lib) mkIf;
cfg = config.ooknet.editor.nvim;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.editor == "nvim") {
programs.nixvim = {
options = {
relativenumber = true;

View file

@ -1,28 +0,0 @@
{ lib, ... }:
{
imports = [
./lf #configuration still needs some work
# ./ranger
];
options.ooknet.console.fileManager = {
lf = {
enable = lib.mkEnableOption "Enable lf file manager";
default = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set lf as the default terminal file manager";
};
};
ranger = {
enable = lib.mkEnableOption "Enable ranger file manager";
default = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Set ranger as the default terminal file manager";
};
};
};
}

View file

@ -1,65 +0,0 @@
{ pkgs, lib, config, ... }:
#TODO - mkif wayland for previewer
# - manage previewer dependencies better
# - ripdrag support
# - color parity with eza
let
cfg = config.ooknet.console.fileManager.lf;
in
{
config = lib.mkIf cfg.enable {
home.sessionVariables.FILEMANAGER = lib.mkIf cfg.default "lf";
xdg.configFile."lf/icons".source = ./icons;
programs.lf = {
enable = true;
settings = {
hidden = true;
ignorecase = true;
drawbox = true;
icons = true;
};
previewer = {
keybinding = "i";
source = "${pkgs.ctpv}/bin/ctpv";
};
commands = {
fzf-lf = ''
''${{
res="$(find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune -o -print 2> /dev/null | sed 1d | cut -b3- | fzf +m)"
if [ -d "$res" ] ; then
cmd="cd"
elif [ -f "$res" ] ; then
cmd="select"
else
exit 0
fi
lf -remote "send $id $cmd \"$res\""
}}
'';
mkdir = ''
''${{
printf "Directory Name: "
read DIR
mkdir $DIR
}}
'';
};
keybindings = {
c = "mkdir";
"<a-f>" = "fzf-lf";
};
extraConfig = ''
&${pkgs.ctpv}/bin/ctpv -s $id
cmd on-quit %${pkgs.ctpv}/bin/ctpv -e $id
set cleaner ${pkgs.ctpv}/bin/ctpvclear
set sixel true
'';
};
home.packages = with pkgs; [ chafa ctpv glow ];
};
}

View file

@ -1,12 +1,14 @@
{ config, lib, pkgs, ... }:
let
cfg = config.ooknet.console.multiplexer.tmux;
inherit (config.colorscheme) palette;
inherit (lib) mkIf;
cfg = config.ooknet.multiplexer.tmux;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.multiplexer == "tmux") {
programs.tmux = {
enable = true;
shell = "${pkgs.fish}/bin/fish";

View file

@ -1,11 +1,13 @@
{ lib, config, pkgs, ... }:
let
inherit (config.colorscheme) palette;
cfg = config.ooknet.console.multiplexer.zellij;
inherit (lib) mkIf;
cfg = config.ooknet.multiplexer.zellij;
console = config.ooknet.console;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || console.multiplexer == "zellij") {
programs.zellij = {
enable = true;
settings = {

View file

@ -1,9 +1,13 @@
{ config, lib, ... }:
{ config, lib, osConfig, ... }:
let
cfg = config.ooknet.console.shell.bash;
inherit (lib) mkIf;
cfg = config.ooknet.shell.bash;
admin = osConfig.ooknet.host.admin;
in
{
config = lib.mkIf cfg.enable {
config = mkIf (cfg.enable || admin.shell == "bash") {
programs.bash.enable = true;
};
}

View file

@ -1,17 +1,7 @@
{ lib, ... }:
{
imports = [
./fish
./bash
./zsh
];
options.ooknet.console.shell = {
fish = {
enable = lib.mkEnableOption "Enable fish configuration";
};
bash = {
enable = lib.mkEnableOption "Enable bash configuration";
};
};
}

View file

@ -1,14 +1,15 @@
{ lib, config, ... }:
{ lib, config, osConfig, ... }:
let
cfg = config.ooknet.console.shell.fish;
inherit (lib) mkIf;
hasPackage = pname: lib.any (p: p ? pname && p.pname == pname) config.home.packages;
inherit (lib) mkIf any;
cfg = config.ooknet.shell.fish;
admin = osConfig.ooknet.host.admin;
hasPackage = pname: any (p: p ? pname && p.pname == pname) config.home.packages;
hasEza = hasPackage "eza";
hasBat = hasPackage "bat";
in
{
config = {
programs.fish = mkIf cfg.enable {
config = mkIf (cfg.enable || admin.shell == "fish") {
programs.fish = {
enable = true;
shellAbbrs = {
fe = "cd $FLAKE; $EDITOR $FLAKE";

View file

@ -1,14 +1,13 @@
{ lib, config, ... }:
{ lib, config, osConfig, ... }:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.ooknet.console.shell.zsh;
inherit (lib) mkIf;
cfg = config.ooknet.shell.zsh;
admin = osConfig.ooknet.host.admin;
in
{
options.ooknet.console.shell.zsh.enable = mkEnableOption "";
config = mkIf cfg.enable {
config = mkIf (cfg.enable || admin.shell == "zsh") {
programs.zsh = {
enable = true;
autocd = true;

View file

@ -0,0 +1,12 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkIf;
cfg = config.ooknet.tools.ffmpeg;
in
{
config = mkIf cfg.enable {
home.packages = [ pkgs.ffmpeg ];
};
}