refactor!: I went too close into the sun
Simlified everything, things were getting out of control
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs;
|
||||
in
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs;
|
||||
in {
|
||||
imports = [
|
||||
./direnv.nix
|
||||
./hyprland.nix
|
||||
@@ -13,6 +15,6 @@ in
|
||||
./wezterm.nix
|
||||
./zsh.nix
|
||||
];
|
||||
options.programs = { };
|
||||
config = { };
|
||||
options.programs = {};
|
||||
config = {};
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.direnv;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.direnv = with lib; with lib.types; { };
|
||||
config = with lib; mkIf cfg.enable {
|
||||
programs.direnv = {
|
||||
enableBashIntegration = mkDefault config.programs.bash.enable;
|
||||
enableFishIntegration = mkDefault config.programs.fish.enable;
|
||||
enableNushellIntegration = mkDefault config.programs.nushell.enable;
|
||||
enableZshIntegration = mkDefault config.programs.zsh.enable;
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.direnv;
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.direnv = with lib; with lib.types; {};
|
||||
config = with lib;
|
||||
mkIf cfg.enable {
|
||||
programs.direnv = {
|
||||
enableBashIntegration = mkDefault config.programs.bash.enable;
|
||||
enableFishIntegration = mkDefault config.programs.fish.enable;
|
||||
enableNushellIntegration = mkDefault config.programs.nushell.enable;
|
||||
enableZshIntegration = mkDefault config.programs.zsh.enable;
|
||||
|
||||
nix-direnv.enable = true;
|
||||
nix-direnv.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
{ config, inputs, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.hyprland;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.hyprland = with lib; with lib.types; {
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.hyprland;
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.hyprland = with lib;
|
||||
with lib.types; {
|
||||
enable = mkEnableOption "";
|
||||
monitors = mkOption {
|
||||
default = [ ];
|
||||
type = listOf (submodule ({ ... }: {
|
||||
default = [];
|
||||
type = listOf (submodule ({...}: {
|
||||
options = {
|
||||
id = mkOption {
|
||||
type = str;
|
||||
@@ -36,15 +40,15 @@ in
|
||||
}));
|
||||
};
|
||||
exec = mkOption {
|
||||
default = [ ];
|
||||
default = [];
|
||||
type = listOf str;
|
||||
};
|
||||
env = mkOption {
|
||||
default = { };
|
||||
default = {};
|
||||
type = attrsOf str;
|
||||
};
|
||||
windowRules = mkOption {
|
||||
default = { };
|
||||
default = {};
|
||||
description = "window = [ \"rule\" ]";
|
||||
type = attrsOf (listOf str);
|
||||
};
|
||||
@@ -117,9 +121,10 @@ in
|
||||
};
|
||||
};
|
||||
workspaces = mkOption {
|
||||
default = [ ];
|
||||
type = listOf
|
||||
(submodule ({ ... }: {
|
||||
default = [];
|
||||
type =
|
||||
listOf
|
||||
(submodule ({...}: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = str;
|
||||
@@ -145,11 +150,11 @@ in
|
||||
type = str;
|
||||
};
|
||||
keyboard = mkOption {
|
||||
default = [ ];
|
||||
default = [];
|
||||
type = listOf str;
|
||||
};
|
||||
mouse = mkOption {
|
||||
default = [ ];
|
||||
default = [];
|
||||
type = listOf str;
|
||||
};
|
||||
};
|
||||
@@ -163,16 +168,18 @@ in
|
||||
|
||||
wayland.windowManager.hyprland.settings = lib.mkMerge [
|
||||
# Sets monitor variables ("$name" = "id") so it can be used in rules later
|
||||
(builtins.listToAttrs (map
|
||||
(m: {
|
||||
name = "\$${m.name}";
|
||||
value = "${m.id}";
|
||||
})
|
||||
cfg.monitors)
|
||||
(
|
||||
builtins.listToAttrs (map
|
||||
(m: {
|
||||
name = "\$${m.name}";
|
||||
value = "${m.id}";
|
||||
})
|
||||
cfg.monitors)
|
||||
)
|
||||
{
|
||||
# Construct the "name,resolution@hz,offset,scale" strings
|
||||
monitor = (map
|
||||
monitor = (
|
||||
map
|
||||
(m: "${m.name},${m.resolution}@${toString m.hz},${m.offset},${toString m.scale}")
|
||||
cfg.monitors
|
||||
);
|
||||
@@ -181,7 +188,8 @@ in
|
||||
|
||||
# "Hack" to transform attributes sets to lists (because I didn't know other way to do it)
|
||||
# Transform { "envName" = "value" } to [ "envName,value" ]
|
||||
env = builtins.attrValues
|
||||
env =
|
||||
builtins.attrValues
|
||||
(builtins.mapAttrs (n: v: "${n},${v}") (lib.attrsets.mergeAttrsList [
|
||||
{
|
||||
"XCURSOR_SIZE" = "24";
|
||||
@@ -190,44 +198,46 @@ in
|
||||
cfg.env
|
||||
]));
|
||||
|
||||
|
||||
windowrulev2 =
|
||||
let
|
||||
firefoxPipRules = [
|
||||
"float"
|
||||
# "nofullscreenrequest"
|
||||
"size 480 270"
|
||||
"fakefullscreen"
|
||||
"nodim"
|
||||
"noblur"
|
||||
];
|
||||
in
|
||||
windowrulev2 = let
|
||||
firefoxPipRules = [
|
||||
"float"
|
||||
# "nofullscreenrequest"
|
||||
"size 480 270"
|
||||
"fakefullscreen"
|
||||
"nodim"
|
||||
"noblur"
|
||||
];
|
||||
in
|
||||
builtins.concatLists
|
||||
(builtins.attrValues (builtins.mapAttrs
|
||||
(w: rs:
|
||||
(map (r: "${r},${w}") rs)
|
||||
)
|
||||
(lib.attrsets.mergeAttrsList [
|
||||
{
|
||||
"title:^(Picture-in-Picture)$,class:^(firefox)$" = firefoxPipRules;
|
||||
"title:^(Firefox)$,class:^(firefox)$" = firefoxPipRules;
|
||||
"title:^(Picture-in-Picture)$" = firefoxPipRules;
|
||||
"class:^(xwaylandvideobridge)$" = [
|
||||
"opacity 0.0 override 0.0 override"
|
||||
"noanim"
|
||||
"nofocus"
|
||||
"noinitialfocus"
|
||||
];
|
||||
}
|
||||
cfg.windowRules
|
||||
])
|
||||
));
|
||||
(builtins.attrValues (
|
||||
builtins.mapAttrs
|
||||
(
|
||||
w: rs: (map (r: "${r},${w}") rs)
|
||||
)
|
||||
(lib.attrsets.mergeAttrsList [
|
||||
{
|
||||
"title:^(Picture-in-Picture)$,class:^(firefox)$" = firefoxPipRules;
|
||||
"title:^(Firefox)$,class:^(firefox)$" = firefoxPipRules;
|
||||
"title:^(Picture-in-Picture)$" = firefoxPipRules;
|
||||
"class:^(xwaylandvideobridge)$" = [
|
||||
"opacity 0.0 override 0.0 override"
|
||||
"noanim"
|
||||
"nofocus"
|
||||
"noinitialfocus"
|
||||
];
|
||||
}
|
||||
cfg.windowRules
|
||||
])
|
||||
));
|
||||
|
||||
input = {
|
||||
kb_layout = cfg.input.keyboard.layout;
|
||||
kb_variant = cfg.input.keyboard.variant;
|
||||
|
||||
follow_mouse = if cfg.input.mouse.follow then "1" else "0";
|
||||
follow_mouse =
|
||||
if cfg.input.mouse.follow
|
||||
then "1"
|
||||
else "0";
|
||||
|
||||
sensitivity = toString cfg.input.mouse.sensitivity;
|
||||
};
|
||||
@@ -244,7 +254,10 @@ in
|
||||
decoration = {
|
||||
rounding = toString cfg.decoration.rouding;
|
||||
|
||||
dim_inactive = if cfg.decoration.dim.inactive then "true" else "false";
|
||||
dim_inactive =
|
||||
if cfg.decoration.dim.inactive
|
||||
then "true"
|
||||
else "false";
|
||||
dim_strength = toString cfg.decoration.dim.strength;
|
||||
dim_around = toString cfg.decoration.dim.around;
|
||||
|
||||
@@ -255,7 +268,10 @@ in
|
||||
};
|
||||
|
||||
animations = {
|
||||
enabled = if cfg.animations.enabled then "yes" else "no";
|
||||
enabled =
|
||||
if cfg.animations.enabled
|
||||
then "yes"
|
||||
else "no";
|
||||
|
||||
bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";
|
||||
|
||||
@@ -282,32 +298,26 @@ in
|
||||
workspace_swipe = "off";
|
||||
};
|
||||
|
||||
workspace =
|
||||
(map
|
||||
(w: "${w.name},${
|
||||
if w.monitor != null then "monitor:${w.monitor}," else ""
|
||||
}${
|
||||
if w.default then "default:true," else ""
|
||||
}${w.extraRules} ")
|
||||
cfg.workspaces
|
||||
);
|
||||
workspace = (
|
||||
map
|
||||
(w: "${w.name},${
|
||||
if w.monitor != null
|
||||
then "monitor:${w.monitor},"
|
||||
else ""
|
||||
}${
|
||||
if w.default
|
||||
then "default:true,"
|
||||
else ""
|
||||
}${w.extraRules} ")
|
||||
cfg.workspaces
|
||||
);
|
||||
|
||||
"$
|
||||
mod " = cfg.binds.mod;
|
||||
|
||||
bind = cfg.binds.keyboard;
|
||||
bindm = cfg.binds.mouse;
|
||||
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.lf;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.lf = with lib; with lib.types; {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.lf;
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.lf = with lib;
|
||||
with lib.types; {
|
||||
cmds = {
|
||||
mkfile = mkOption {
|
||||
type = bool;
|
||||
@@ -29,25 +32,25 @@ in
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
config = with lib; mkIf cfg.enable {
|
||||
programs.lf = {
|
||||
commands = {
|
||||
dragon-out = mkIf cfg.cmds.dragon-out ''%${pkgs.xdragon}/bin/xdragon -a -x "$fx"'';
|
||||
editor-open = mkIf cfg.cmds.editor-open ''$$EDITOR $f'';
|
||||
mkfile = mkIf cfg.cmds.mkfile ''''${{
|
||||
printf "Dirname: "
|
||||
read DIR
|
||||
config = with lib;
|
||||
mkIf cfg.enable {
|
||||
programs.lf = {
|
||||
commands = {
|
||||
dragon-out = mkIf cfg.cmds.dragon-out ''%${pkgs.xdragon}/bin/xdragon -a -x "$fx"'';
|
||||
editor-open = mkIf cfg.cmds.editor-open ''$$EDITOR $f'';
|
||||
mkfile = mkIf cfg.cmds.mkfile '' ''${{
|
||||
printf "Dirname: "
|
||||
read DIR
|
||||
|
||||
if [[ $DIR = */ ]]; then
|
||||
mkdir $DIR
|
||||
else
|
||||
touch $DIR
|
||||
fi
|
||||
}}'';
|
||||
};
|
||||
if [[ $DIR = */ ]]; then
|
||||
mkdir $DIR
|
||||
else
|
||||
touch $DIR
|
||||
fi
|
||||
}}'';
|
||||
};
|
||||
|
||||
extraConfig =
|
||||
let
|
||||
extraConfig = let
|
||||
previewer = pkgs.writeShellScriptBin "pv.sh" ''
|
||||
file=$1
|
||||
w=$2
|
||||
@@ -66,14 +69,18 @@ in
|
||||
${pkgs.kitty}/bin/kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty
|
||||
'';
|
||||
in
|
||||
mkDefault ''
|
||||
${if cfg.filePreviewer then ''
|
||||
set cleaner ${cleaner}/bin/clean.sh
|
||||
set previewer ${previewer}/bin/pv.sh
|
||||
'' else ""}
|
||||
mkDefault ''
|
||||
${
|
||||
if cfg.filePreviewer
|
||||
then ''
|
||||
set cleaner ${cleaner}/bin/clean.sh
|
||||
set previewer ${previewer}/bin/pv.sh
|
||||
''
|
||||
else ""
|
||||
}
|
||||
|
||||
${cfg.extraCfg}
|
||||
'';
|
||||
${cfg.extraCfg}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.starship;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.starship = with lib; with lib.types; { };
|
||||
config = with lib; mkIf cfg.enable {
|
||||
programs.starship = {
|
||||
enableFishIntegration = mkDefault config.programs.fish.enable;
|
||||
enableIonIntegration = mkDefault config.programs.ion.enable;
|
||||
enableNushellIntegration = mkDefault config.programs.nushell.enable;
|
||||
enableZshIntegration = mkDefault config.programs.zsh.enable;
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.starship;
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.starship = with lib; with lib.types; {};
|
||||
config = with lib;
|
||||
mkIf cfg.enable {
|
||||
programs.starship = {
|
||||
enableFishIntegration = mkDefault config.programs.fish.enable;
|
||||
enableIonIntegration = mkDefault config.programs.ion.enable;
|
||||
enableNushellIntegration = mkDefault config.programs.nushell.enable;
|
||||
enableZshIntegration = mkDefault config.programs.zsh.enable;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.tmux;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.tmux = with lib; with lib.types; { };
|
||||
config = with lib; mkIf cfg.enable { };
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.tmux;
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.tmux = with lib; with lib.types; {};
|
||||
config = with lib; mkIf cfg.enable {};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +1,47 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with builtins;
|
||||
let
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with builtins; let
|
||||
cfg = config.programs.wezterm;
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
toLua = with lib.strings; v:
|
||||
if isList v then
|
||||
"{ ${concatMapStringsSep ", " (i: toLua i) v} }"
|
||||
else if isAttrs v then
|
||||
"\{ ${concatStringsSep ", " (attrValues (mapAttrs (n: a: "${n} = ${toLua a}") v))} \}"
|
||||
else if isNull v then
|
||||
"nil"
|
||||
else if isBool v then
|
||||
if v then "true" else "false"
|
||||
else if isInt v then
|
||||
toString v
|
||||
else if isString v && hasPrefix "lua " v then
|
||||
"${substring 4 (stringLength v) v}"
|
||||
else
|
||||
"\"${toString v}\"";
|
||||
configInLua =
|
||||
pkgs.writeText "nih-wezterm-generated-config" ''
|
||||
local wezterm = require("wezterm");
|
||||
jsonFormat = pkgs.formats.json {};
|
||||
toLua = with lib.strings;
|
||||
v:
|
||||
if isList v
|
||||
then "{ ${concatMapStringsSep ", " (i: toLua i) v} }"
|
||||
else if isAttrs v
|
||||
then "\{ ${concatStringsSep ", " (attrValues (mapAttrs (n: a: "${n} = ${toLua a}") v))} \}"
|
||||
else if isNull v
|
||||
then "nil"
|
||||
else if isBool v
|
||||
then
|
||||
if v
|
||||
then "true"
|
||||
else "false"
|
||||
else if isInt v
|
||||
then toString v
|
||||
else if isString v && hasPrefix "lua " v
|
||||
then "${substring 4 (stringLength v) v}"
|
||||
else "\"${toString v}\"";
|
||||
configInLua = pkgs.writeText "nih-wezterm-generated-config" ''
|
||||
local wezterm = require("wezterm");
|
||||
|
||||
local nih_generated_config = {};
|
||||
${concatStringsSep "\n" (attrValues (mapAttrs
|
||||
(n: v: "nih_generated_config.${n} = ${toLua v};")
|
||||
cfg.config))}
|
||||
local nih_generated_config = {};
|
||||
${concatStringsSep "\n" (attrValues (mapAttrs
|
||||
(n: v: "nih_generated_config.${n} = ${toLua v};")
|
||||
cfg.config))}
|
||||
|
||||
local function extra_config()
|
||||
${cfg.extraConfig}
|
||||
end
|
||||
local function extra_config()
|
||||
${cfg.extraConfig}
|
||||
end
|
||||
|
||||
for k,v in pairs(extra_config()) do nih_generated_config[k] = v end
|
||||
for k,v in pairs(extra_config()) do nih_generated_config[k] = v end
|
||||
|
||||
return nih_generated_config;
|
||||
'';
|
||||
prettyConfig = pkgs.runCommand "nih-wezterm-pretty-config" { config = configInLua; } ''
|
||||
return nih_generated_config;
|
||||
'';
|
||||
prettyConfig = pkgs.runCommand "nih-wezterm-pretty-config" {config = configInLua;} ''
|
||||
echo "Nih's Wezterm configuration file builder";
|
||||
echo "input file: $config";
|
||||
echo "output file: $out";
|
||||
@@ -50,27 +55,24 @@ let
|
||||
--no-unused \
|
||||
"$out";
|
||||
'';
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.wezterm = with lib; with lib.types; {
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.wezterm = with lib;
|
||||
with lib.types; {
|
||||
config = mkOption {
|
||||
type = submodule ({ ... }: {
|
||||
type = submodule ({...}: {
|
||||
freeformType = jsonFormat.type;
|
||||
});
|
||||
default = { };
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
config = with lib; mkIf cfg.enable {
|
||||
programs.wezterm = {
|
||||
enableBashIntegration = mkDefault config.programs.bash.enable;
|
||||
enableZshIntegration = mkDefault config.programs.zsh.enable;
|
||||
};
|
||||
config = with lib;
|
||||
mkIf cfg.enable {
|
||||
programs.wezterm = {
|
||||
enableBashIntegration = mkDefault config.programs.bash.enable;
|
||||
enableZshIntegration = mkDefault config.programs.zsh.enable;
|
||||
};
|
||||
|
||||
xdg.configFile."wezterm/wezterm.lua".source = prettyConfig;
|
||||
};
|
||||
xdg.configFile."wezterm/wezterm.lua".source = prettyConfig;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.zsh;
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
options.programs.zsh = with lib; with lib.types; { };
|
||||
config = with lib; mkIf cfg.enable { };
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.zsh;
|
||||
in {
|
||||
imports = [];
|
||||
options.programs.zsh = with lib; with lib.types; {};
|
||||
config = with lib; mkIf cfg.enable {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user