organise all options into modules

This commit is contained in:
atagen 2024-05-08 15:05:43 +10:00
parent c7c6606d14
commit 3192b6ca09
43 changed files with 518 additions and 423 deletions

View file

@ -9,51 +9,14 @@
imports = [
./home.nix
./util/local-webapp.nix
./programs/stable-diffusion.nix
./programs/ollama.nix
];
home = {
username = "bolt";
homeDirectory = "/home/bolt";
packages = with pkgs; [
nicotine-plus
];
};
localWebApps = {
stable-diffusion = {
name = "Stable Diffusion (ComfyUI)";
genericName = "Stable Diffusion";
icon = ./icons/comfyui.png;
id = 5;
port = 7860;
service = {
WorkingDirectory = "${config.home.homeDirectory}/code/etc/stable-diffusion-webui-docker";
ExecStart = "${lib.getExe pkgs.docker} compose --profile comfy up --build";
};
};
openwebui = rec {
name = "Ollama (OpenWebUI)";
genericName = "Ollama";
icon = ./icons/openwebui.png;
id = 6;
port = 3021;
service = let
docker = lib.getExe pkgs.docker;
in {
Type = "exec";
ExecStartPre = "${pkgs.writeShellScript "openwebui-check" ''
set -euo pipefail
echo Checking for container existence..
if [[ $(${docker} inspect openwebui &> /dev/null; printf $?) -ne 0 ]]; then
echo Not found. Creating OpenWebUI/Ollama container..
${docker} create -e PORT=${builtins.toString port} --network host --gpus all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name openwebui --restart always ghcr.io/open-webui/open-webui:ollama
fi
echo Check complete.
''}";
ExecStart = "${docker} start -a openwebui";
ExecStop = "${docker} stop openwebui";
};
};
};
services.flatpak.packages = ["org.nicotine_plus.Nicotine"];
}

View file

@ -1,79 +1,33 @@
{
inputs,
outputs,
lib,
config,
pkgs,
...
}: let
palette-hex = pkgs.lib.nix-rice.palette.toRgbHex pkgs.rice.palette;
palette-shex = pkgs.lib.nix-rice.palette.toRGBShortHex pkgs.rice.palette;
inherit (lib) getExe;
in {
home.stateVersion = "22.11";
imports = [
./programs/helix.nix
./programs/firefox.nix
./programs/kitty.nix
./programs/zsh.nix
./programs/cli.nix
./programs/desktop.nix
./programs/dev.nix
./programs/theming.nix
./util/ez.nix
./util/firefox-webapp.nix
# inputs.plasma-manager.homeManagerModules.plasma-manager
# ./programs/plasma.nix
inputs.nix-index-database.hmModules.nix-index
];
nix.gc = {
automatic = true;
frequency = "weekly";
options = "--delete-older-than 7d";
frequency = "daily";
options = "--delete-older-than 3d";
};
xdg.enable = true;
home.packages = with pkgs;
[
thunderbird
strawberry
inkscape
imv
zathura
btop
bat
ripgrep
fd
lazygit
fzf
zoxide
zellij
libnotify
playerctl
# kooha
croc
xorg.xrdb
culr
tuxguitar
# kdeconnect
# plasma-browser-integration
keepassxc
git-credential-keepassxc
direnv
mpv
gtk-engine-murrine
# polonium-pkgs.pkgs.plasma5Packages.polonium
]
++ pkgs.rice.fonts.pkgs
++ pkgs.rice.icons.pkgs;
rice.fonts.pkgs
++ rice.icons.pkgs;
systemd.user.targets.tray = {
Unit = {
@ -82,80 +36,12 @@ in {
};
};
fonts.fontconfig.enable = true;
services.syncthing = {
enable = true;
};
services.udiskie.enable = true;
services.flatpak = {
enable = true;
uninstallUnmanaged = true;
update.auto.enable = true;
packages = [
"md.obsidian.Obsidian"
"org.onlyoffice.desktopeditors"
];
overrides = {
global = {
Context.sockets = ["wayland"];
Environment = {
ELECTRON_OZONE_PLATFORM_HINT = "auto";
};
};
"md.obsidian.Obsidian" = {
Environment = {
OBSIDIAN_DISABLE_GPU = "1";
};
};
};
};
programs.firefox.webapps = {
"Microsoft-Teams" = {
url = "https://teams.microsoft.com";
id = 1;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "Microsoft Teams";
icon = ./icons/ms_teams.png;
};
"Facebook-Messenger" = {
url = "https://www.messenger.com";
id = 2;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "Facebook Messenger";
icon = ./icons/fb_msg.png;
};
"Syncthing" = {
url = "http://127.0.0.1:8384";
id = 3;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "Syncthing";
icon = ./icons/syncthing.png;
};
"StudyTAFE" = {
url = "https://www.studytafensw.edu.au";
id = 4;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "TAFE Study";
icon = ./icons/tafe.jpg;
};
};
programs.atuin = {
enable = true;
enableZshIntegration = true;
settings = {
inline_height = 20;
show_preview = true;
show_help = false;
enter_accept = false;
keymap_mode = "vim-normal";
style = "compact";
};
};
# programs.nix-index-database.comma.enable = true;
# programs.nix-index = {
# enable = true;
@ -165,108 +51,8 @@ in {
# programs.command-not-found.enable = false;
# programs.nix-index.enable = true;
programs.vscode = {
enable = true;
extensions = with pkgs.vscode-extensions; [
rust-lang.rust-analyzer
serayuzgur.crates
jnoortheen.nix-ide
arrterian.nix-env-selector
mkhl.direnv
# silverquark.dancehelix
# gregoire.dance
];
mutableExtensionsDir = true;
userSettings = {
"window.titleBarStyle" = "custom";
"editor.fontFamily" = "${pkgs.rice.fonts.monospace.name}";
"editor.fontSize" = 12;
"workbench.colorTheme" = "KanagawaTheme";
"rust-analyzer.check.overrideCommand" = "clippy";
"rust-analyzer.debug.engine" = "vadimcn.vscode-lldb";
"rust-analyzer.inlayHints.chainingHints.enable" = false;
"rust-analyzer.inlayHints.parameterHints.enable" = false;
"rust-analyzer.inlayHints.typeHints.enable" = false;
};
};
systemd.user.startServices = "sd-switch";
ezServices = with pkgs; {
ckb-next = "${lib.getExe ckb-next} -c -b";
ezServices = {
ckb-next = "${getExe pkgs.ckb-next} -c -b";
};
ezOneShots = with pkgs; {
xrdb = "${lib.getExe xorg.xrdb} -load ${config.home.homeDirectory}/.Xresources";
};
xdg.enable = true;
xresources.properties = with palette-hex; {
"*.foreground" = util.fg;
"*.background" = util.bg;
"*.cursorColor" = util.cursor;
"*.selection_foreground" = util.fg_sel;
"*.selection_background" = util.bg_sel;
"*.color0" = normal.black;
"*.color1" = normal.red;
"*.color2" = normal.green;
"*.color3" = normal.yellow;
"*.color4" = normal.blue;
"*.color5" = normal.magenta;
"*.color6" = normal.cyan;
"*.color7" = normal.white;
"*.color8" = bright.black;
"*.color9" = bright.red;
"*.color10" = bright.green;
"*.color11" = bright.yellow;
"*.color12" = bright.blue;
"*.color13" = bright.magenta;
"*.color14" = bright.cyan;
"*.color15" = bright.white;
};
xdg.systemDirs.data = [
"${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}"
"${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}"
];
# gtk = with pkgs.rice; {
# enable = true;
# theme = with gtk-theme; {
# inherit package name;
# };
# iconTheme = with icons; {
# inherit package name;
# };
# font = with fonts.sans; {
# inherit name size package;
# };
# };
programs.direnv = {
enable = true;
nix-direnv = {
enable = true;
};
};
programs.git = {
enable = true;
userName = "atagen";
userEmail = "atagen@boss.co";
extraConfig = {
credential.helper = "keepassxc";
};
};
# programs.fzf = {
# enable = true;
# enableZshIntegration = true;
# colors = with palette-hex; {
# fg = util.fg;
# bg = util.bg;
# hl = util.bg_sel;
# "fg+" = util.fg_sel;
# "bg+" = util.bg_sel;
# "hl+" = bright.green;
# };
# };
}

16
home/programs/atuin.nix Normal file
View file

@ -0,0 +1,16 @@
{...}:
{
programs.atuin = {
enable = true;
enableZshIntegration = true;
settings = {
inline_height = 20;
show_preview = true;
show_help = false;
enter_accept = false;
keymap_mode = "vim-normal";
style = "compact";
};
};
}

18
home/programs/cli.nix Normal file
View file

@ -0,0 +1,18 @@
{pkgs, ...}: {
imports = [
./kitty.nix
./zsh.nix
./xresources.nix
./helix.nix
./atuin.nix
];
home.packages = with pkgs; [
btop
bat
ripgrep
fd
lazygit
zoxide
zellij
];
}

View file

@ -0,0 +1,7 @@
{...}: {
flatpaks = [
"ar.com.tuxguitar.TuxGuitar"
"org.inkscape.Inkscape"
"com.github.PintaProject.Pinta"
];
}

17
home/programs/desktop.nix Normal file
View file

@ -0,0 +1,17 @@
{pkgs, ...}: {
imports = [
./media-players.nix
./firefox.nix
./flatpak.nix
./webapps.nix
./vscode.nix
./documents.nix
./creative.nix
];
home.packages = with pkgs; [
gnome.file-roller
gnome.nautilus
thunderbird
keepassxc
];
}

22
home/programs/dev.nix Normal file
View file

@ -0,0 +1,22 @@
{pkgs, ...}: {
home.packages = with pkgs; [
git-credential-keepassxc
direnv
];
programs.direnv = {
enable = true;
nix-direnv = {
enable = true;
};
};
programs.git = {
enable = true;
userName = "atagen";
userEmail = "atagen@boss.co";
extraConfig = {
credential.helper = "keepassxc";
};
};
}

View file

@ -0,0 +1,15 @@
{...}: {
flatpaks = [
{
name = "md.obsidian.Obsidian";
overrides = {
Environment = {
OBSIDIAN_DISABLE_GPU = "1";
};
};
}
# "org.onlyoffice.desktopeditors"
"org.libreoffice.LibreOffice"
"com.jgraph.drawio.desktop"
];
}

View file

@ -16,7 +16,7 @@
Status = "locked";
};
in {
config.programs.firefox = {
programs.firefox = {
enable = true;
policies = {

63
home/programs/flatpak.nix Normal file
View file

@ -0,0 +1,63 @@
{
config,
lib,
...
}: let
inherit (lib) mkOption;
inherit (builtins) typeOf listToAttrs;
in {
options.flatpaks = mkOption {
default = [];
type = with lib.types;
listOf (either str (submodule {
options = {
name = mkOption {
type = str;
};
overrides = mkOption {
type = attrsOf (attrsOf (either str (listOf str)));
default = {};
};
};
}));
};
config.services.flatpak = let
userOverrides = listToAttrs (
map (
fp:
if (typeOf fp == "string")
then {
name = fp;
value = {};
}
else {
inherit (fp) name;
value = fp.overrides;
}
)
config.flatpaks
);
in {
enable = true;
uninstallUnmanaged = true;
update.auto.enable = true;
packages =
map (
fp:
if (typeOf fp == "set")
then fp.name
else fp
)
config.flatpaks;
overrides =
userOverrides
// {
global = {
Context.sockets = ["wayland"];
Environment = {
ELECTRON_OZONE_PLATFORM_HINT = "auto";
};
};
};
};
}

View file

@ -7,7 +7,7 @@
palette-hex = pkgs.lib.nix-rice.palette.toRgbHex pkgs.rice.palette;
palette-shex = pkgs.lib.nix-rice.palette.toRGBShortHex pkgs.rice.palette;
in {
config.programs.helix = {
programs.helix = {
enable = true;
themes = with palette-hex; {
nix-rice = {

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 183 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 152 KiB

Before After
Before After

View file

@ -0,0 +1,10 @@
{pkgs, ...}: {
home.packages = with pkgs; [
mpv
imv
strawberry
zathura
# libnotify
playerctl
];
}

35
home/programs/ollama.nix Normal file
View file

@ -0,0 +1,35 @@
{
lib,
pkgs,
...
}: let
inherit (lib) getExe;
inherit (builtins) toString;
inherit (pkgs) writeShellScript;
in {
localWebApps = {
openwebui = rec {
name = "Ollama (OpenWebUI)";
genericName = "Ollama";
icon = ./icons/openwebui.png;
id = 6;
port = 3021;
service = let
docker = getExe pkgs.docker;
in {
Type = "exec";
ExecStartPre = "${writeShellScript "openwebui-check" ''
set -euo pipefail
echo Checking for container existence..
if [[ $(${docker} inspect openwebui &> /dev/null; printf $?) -ne 0 ]]; then
echo Not found. Creating OpenWebUI/Ollama container..
${docker} create -e PORT=${toString port} --network host --gpus all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name openwebui --restart always ghcr.io/open-webui/open-webui:ollama
fi
echo Check complete.
''}";
ExecStart = "${docker} start -a openwebui";
ExecStop = "${docker} stop openwebui";
};
};
};
}

View file

@ -0,0 +1,23 @@
{
lib,
pkgs,
config,
...
}: let
inherit (lib) getExe;
inherit (config.home) homeDirectory;
in {
localWebApps = {
stable-diffusion = {
name = "Stable Diffusion (ComfyUI)";
genericName = "Stable Diffusion";
icon = ./icons/comfyui.png;
id = 5;
port = 7860;
service = {
WorkingDirectory = "${homeDirectory}/code/etc/stable-diffusion-webui-docker";
ExecStart = "${getExe pkgs.docker} compose --profile comfy up --build";
};
};
};
}

30
home/programs/theming.nix Normal file
View file

@ -0,0 +1,30 @@
{pkgs, ...}: {
home.packages = with pkgs; [
gtk-engine-murrine
];
fonts.fontconfig.enable = true;
qt = {
enable = true;
style.name = "adwaita-dark";
platformTheme.name = "adwaita";
};
gtk = with pkgs;
with rice; {
enable = true;
# theme = with gtk-theme; {
# inherit package name;
# };
theme = {
name = "adw-gtk3-dark";
package = adw-gtk3; # cosmic
};
iconTheme = with icons; {
inherit package name;
};
font = with fonts.sans; {
inherit name size package;
};
};
}

26
home/programs/vscode.nix Normal file
View file

@ -0,0 +1,26 @@
{pkgs, ...}: {
programs.vscode = {
enable = true;
extensions = with pkgs.vscode-extensions; [
rust-lang.rust-analyzer
serayuzgur.crates
jnoortheen.nix-ide
arrterian.nix-env-selector
mkhl.direnv
# silverquark.dancehelix
# gregoire.dance
];
mutableExtensionsDir = true;
userSettings = {
"window.titleBarStyle" = "custom";
"editor.fontFamily" = "${pkgs.rice.fonts.monospace.name}";
"editor.fontSize" = 12;
"workbench.colorTheme" = "KanagawaTheme";
"rust-analyzer.check.overrideCommand" = "clippy";
"rust-analyzer.debug.engine" = "vadimcn.vscode-lldb";
"rust-analyzer.inlayHints.chainingHints.enable" = false;
"rust-analyzer.inlayHints.parameterHints.enable" = false;
"rust-analyzer.inlayHints.typeHints.enable" = false;
};
};
}

35
home/programs/webapps.nix Normal file
View file

@ -0,0 +1,35 @@
{config, ...}: {
imports = [
../util/firefox-webapp.nix
];
programs.firefox.webapps = {
"Microsoft-Teams" = {
url = "https://teams.microsoft.com";
id = 1;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "Microsoft Teams";
icon = ./icons/ms_teams.png;
};
"Facebook-Messenger" = {
url = "https://www.messenger.com";
id = 2;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "Facebook Messenger";
icon = ./icons/fb_msg.png;
};
"Syncthing" = {
url = "http://127.0.0.1:8384";
id = 3;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "Syncthing";
icon = ./icons/syncthing.png;
};
"StudyTAFE" = {
url = "https://www.studytafensw.edu.au";
id = 4;
extraSettings = config.programs.firefox.profiles.default.settings;
name = "TAFE Study";
icon = ./icons/tafe.jpg;
};
};
}

View file

@ -7,7 +7,7 @@
palette-hex = pkgs.lib.nix-rice.palette.toRgbHex pkgs.rice.palette;
palette-shex = pkgs.lib.nix-rice.palette.toRGBShortHex pkgs.rice.palette;
in {
config.programs.wlogout = {
programs.wlogout = {
enable = true;
layout = builtins.fromJSON (builtins.readFile ../dots/wlogout/layout);
style = with palette-hex; (builtins.replaceStrings

View file

@ -0,0 +1,41 @@
{
pkgs,
lib,
config,
...
}: let
inherit (lib) getExe;
inherit (config.home) homeDirectory;
palette-hex = pkgs.lib.nix-rice.palette.toRgbHex pkgs.rice.palette;
in {
ezOneShots = with pkgs; {
xrdb = "${getExe xorg.xrdb} -load ${homeDirectory}/.Xresources";
};
home.packages = with pkgs; [
xorg.xrdb
culr
];
xresources.properties = with palette-hex; {
"*.foreground" = util.fg;
"*.background" = util.bg;
"*.cursorColor" = util.cursor;
"*.selection_foreground" = util.fg_sel;
"*.selection_background" = util.bg_sel;
"*.color0" = normal.black;
"*.color1" = normal.red;
"*.color2" = normal.green;
"*.color3" = normal.yellow;
"*.color4" = normal.blue;
"*.color5" = normal.magenta;
"*.color6" = normal.cyan;
"*.color7" = normal.white;
"*.color8" = bright.black;
"*.color9" = bright.red;
"*.color10" = bright.green;
"*.color11" = bright.yellow;
"*.color12" = bright.blue;
"*.color13" = bright.magenta;
"*.color14" = bright.cyan;
"*.color15" = bright.white;
};
}

View file

@ -22,7 +22,7 @@
default = {};
};
# for launching a systemd target on wm startup
# for specifying an additional systemd target
extraTarget = with lib;
mkOption {
type = with types; listOf str;

View file

@ -4,7 +4,7 @@
...
}: let
inherit (builtins) getAttr stringLength substring;
inherit (lib) mkOption;
inherit (lib) mkOption getExe;
inherit (lib.attrsets) filterAttrs mapAttrs mapAttrs' nameValuePair;
inherit (lib.strings) concatStringsSep toUpper;
@ -190,7 +190,7 @@ in {
type = "Application";
exec = concatStringsSep " " ([
"${lib.getExe config.programs.firefox.package}"
"${getExe config.programs.firefox.package}"
"--name"
"${name}"
"--app-id"

View file

@ -6,6 +6,7 @@
}: let
inherit (lib) mkOption;
inherit (lib.attrsets) mapAttrs mapAttrs' nameValuePair;
inherit (lib) getExe getExe';
# make a firefox webapp entry for the client app
make-firefox = cfg:
mapAttrs' (
@ -35,10 +36,10 @@
inherit (cfg) name icon genericName;
type = "Application";
exec = "${let
notify-send = "${lib.getExe' pkgs.libnotify "notify-send"} -a \"${cfg.name}\"";
systemctl = "${lib.getExe' pkgs.systemd "systemctl"}";
dex = "${lib.getExe pkgs.dex}";
curl = "${lib.getExe pkgs.curl}";
notify-send = "${getExe' pkgs.libnotify "notify-send"} -a \"${cfg.name}\"";
systemctl = "${getExe' pkgs.systemd "systemctl"}";
dex = "${getExe pkgs.dex}";
curl = "${getExe pkgs.curl}";
in
pkgs.writeShellScript "${name}"
''