Add basic theme config

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-23 14:50:50 +03:00
parent 48f391e3ad
commit e7d328cab5
23 changed files with 554 additions and 188 deletions

View File

@@ -0,0 +1,3 @@
git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
--in-place "$1"

View File

@@ -2,7 +2,8 @@
let
hmConfig = config.home-manager.users."${user.name}";
in {
in
{
home-manager.users."${user.name}" = {
programs.git = {
enable = true;
@@ -14,14 +15,13 @@ in {
key = null;
};
extraConfig.credential.helper = "store";
hooks = let
commit-msg-hook = pkgs.writeShellScriptBin "git-commit-msg" ''
${pkgs.git}/bin/git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
--in-place "$1"
'';
in {
commit-msg = "${commit-msg-hook}/bin/git-commit-msg";
hooks = {
commit-msg = let name = "git-commit-msg-hook"; in
"${pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [ git ];
text = builtins.readFile ./commit-msg.sh;
}}/bin/${name}";
};
};

View File

@@ -18,42 +18,38 @@ in
};
systemd.user = {
services.gpg-agent-import = let
init = pkgs.writeShellScriptBin "import-gpg-keys" ''
export GNUPGHOME=${gpgPath}
services.gpg-agent-import =
let
name = "import-gpg-keys";
init = pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [
coreutils-full
gnugrep
gnupg
];
runtimeEnv = {
GNUPGHOME = gpgPath;
HOME = user.home;
};
text = builtins.readFile ./import-gpg-keys.sh;
};
in
{
Unit = {
Description = "Auto-import GPG keys";
Requires = [ "sops-nix.service" "gpg-agent.socket" ];
After = [ "sops-nix.service" "gpg-agent.socket" ];
};
for keyfile in "${user.home}"/.config/sops-nix/secrets/gpg-agent/*.key; do
passfile="''${keyfile%.key}.pass"
Service = {
Type = "oneshot";
ExecStart = "${init}/bin/${name}";
};
if [ -f "$passfile" ]; then
${pkgs.gnupg}/bin/gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
else
${pkgs.gnupg}/bin/gpg2 --batch --yes --import "$keyfile"
fi
${pkgs.gnupg}/bin/gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
echo "$KEY_ID:6:" >> "${gpgPath}"/otrust.txt
done
done
${pkgs.gnupg}/bin/gpg2 --import-ownertrust "${gpgPath}"/otrust.txt
rm "${gpgPath}"/otrust.txt
'';
in {
Unit = {
Description = "Auto-import GPG keys";
Requires = [ "sops-nix.service" "gpg-agent.socket" ];
After = [ "sops-nix.service" "gpg-agent.socket" ];
Install.WantedBy = [ "default.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${init}/bin/import-gpg-keys";
};
Install = { WantedBy = [ "default.target" ]; };
};
tmpfiles.rules = [ "d ${hmConfig.xdg.dataHome}/gnupg 0700 ${user.name} users -" ];
};

View File

@@ -0,0 +1,16 @@
for keyfile in "$HOME"/.config/sops-nix/secrets/gpg-agent/*.key; do
passfile="${keyfile%.key}.pass"
if [ -f "$passfile" ]; then
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
else
gpg2 --batch --yes --import "$keyfile"
fi
gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
echo "$KEY_ID:6:" >> "$GNUPGHOME"/otrust.txt
done
done
gpg2 --import-ownertrust "$GNUPGHOME"/otrust.txt
rm "$GNUPGHOME"/otrust.txt

View File

@@ -96,24 +96,12 @@ in
"disable_hyprland_logo" = true;
"disable_splash_rendering" = true;
};
exec-once = let
init = pkgs.writeShellScriptBin "hyprland-init" ''
${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log &
while ! ${pkgs.swww}/bin/swww query &> /dev/null; do
sleep 0.1
done
${pkgs.swww}/bin/swww img ${user.wallpaper}
'';
in "${init}/bin/hyprland-init";
};
};
programs.zsh.loginExtra = lib.mkAfter ''
if [ -z "''${WAYLAND_DISPLAY}" ] && [ ! -z "''${XDG_VTNR}" ] && [ "''${XDG_VTNR}" -eq 1 ]; then
${pkgs.hyprland}/bin/hyprland &> /tmp/hyprland.log
if [ -z "''${WAYLAND_DISPLAY}" ] && [ -n "''${XDG_VTNR}" ] && [ "''${XDG_VTNR}" -eq 1 ]; then
hyprland &> /tmp/hyprland.log
fi
'';

View File

@@ -0,0 +1,58 @@
{ user ? throw "user argument is required" }: { config, ... }:
let
hmConfig = config.home-manager.users."${user.name}";
in
{
home-manager.users."${user.name}" = {
programs.matugen = {
enable = true;
settings = {
config = {
custom_colors =
let
mkColor = category: color: {
color = hmConfig.theme.color.${category}.${color};
blend = hmConfig.theme.color.${category}.blend;
};
in
{
danger = mkColor "semantic" "danger";
warning = mkColor "semantic" "warning";
success = mkColor "semantic" "success";
info = mkColor "semantic" "info";
red = mkColor "ansi" "red";
green = mkColor "ansi" "green";
yellow = mkColor "ansi" "yellow";
orange = mkColor "ansi" "orange";
blue = mkColor "ansi" "blue";
magenta = mkColor "ansi" "magenta";
cyan = mkColor "ansi" "cyan";
keywords = mkColor "syntax" "keywords";
functions = mkColor "syntax" "functions";
properties = mkColor "syntax" "properties";
constants = mkColor "syntax" "constants";
strings = mkColor "syntax" "strings";
numbers = mkColor "syntax" "numbers";
structures = mkColor "syntax" "structures";
types = mkColor "syntax" "types";
};
custom_keywords = {
flavour = hmConfig.theme.flavour;
contrast = builtins.toString hmConfig.theme.contrast;
opacity = builtins.toString hmConfig.theme.opacity;
radius = builtins.toString hmConfig.theme.radius;
padding = builtins.toString hmConfig.theme.padding;
double_padding = builtins.toString (hmConfig.theme.padding * 2);
blur = builtins.toString hmConfig.theme.blur;
};
};
templates = { };
};
};
};
}

View File

@@ -1,13 +0,0 @@
{ user ? throw "user argument is required" }: { inputs, ... }:
{
home-manager.users."${user.name}" = {
imports = [ inputs.stylix.homeManagerModules.stylix ];
stylix = {
enable = true;
image = user.wallpaper;
base16Scheme = user.base16Scheme;
};
};
}

View File

@@ -1,10 +1,33 @@
{ user ? throw "user argument is required" }: { pkgs, ... }:
{ user ? throw "user argument is required" }: { config, pkgs, ... }:
let
hmConfig = config.home-manager.users."${user.name}";
in
{
home-manager.users."${user.name}" = {
home = {
packages = with pkgs; [ swww ];
persistence."/cache${user.home}".directories = [ ".cache/swww" ];
};
theme.extraConfig = let name = "theme-swww"; in
"${pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [
coreutils-full
swww
];
text = ''
if ! pgrep -x "swww-daemon" > /dev/null; then
swww-daemon &> /tmp/swww.log &
fi
while ! swww query &> /dev/null; do
sleep 0.1
done
swww img "${hmConfig.theme.configDir}/wallpaper"
'';
}}/bin/${name}";
};
}

View File

@@ -0,0 +1,8 @@
{ user ? throw "user argument is required" }: { pkgs, ... }:
{
home-manager.users."${user.name}" = {
theme.enable = true;
home.persistence."/persist${user.home}".directories = [ ".config/theme" ];
};
}

View File

@@ -1,27 +1,12 @@
{ user ? throw "user argument is required" }: { inputs, lib, pkgs, ... }:
let
configDir = ".config/Code";
cacheDirs = [
".config/Code/Cache"
".config/Code/CachedConfigurations"
".config/Code/CachedData"
".config/Code/CachedExtensionVSIXs"
".config/Code/CachedExtensions"
".config/Code/CachedProfilesData"
".config/Code/Code Cache"
".config/Code/DawnCache"
".config/Code/GPUCache"
".config/Code/Service Worker/CacheStorage"
".config/Code/Service Worker/ScriptCache"
];
inherit (pkgs.callPackage "${inputs.impermanence}/lib.nix" { }) sanitizeName concatPaths;
in {
{
home-manager.users."${user.name}" = {
programs.vscode = {
enable = true;
mutableExtensionsDir = false;
userSettings = {
"diffEditor.ignoreTrimWhitespace" = false;
"editor.accessibilitySupport" = "off";
"editor.cursorBlinking" = "phase";
"editor.cursorSmoothCaretAnimation" = "on";
@@ -76,27 +61,24 @@ in {
];
home.persistence = {
"/persist${user.home}".directories = [ configDir ];
"/persist${user.home}".directories = [ ".config/Code" ];
# Bastard: https://github.com/microsoft/vscode/issues/3884
"/cache${user.home}".directories = cacheDirs;
# Even bigger Bastards:
# - https://github.com/nix-community/impermanence/issues/22
# - https://github.com/nix-community/impermanence/pull/97
# "/cache${user.home}".directories = [
# ".config/Code/Cache"
# ".config/Code/CachedConfigurations"
# ".config/Code/CachedData"
# ".config/Code/CachedExtensionVSIXs"
# ".config/Code/CachedExtensions"
# ".config/Code/CachedProfilesData"
# ".config/Code/Code Cache"
# ".config/Code/DawnCache"
# ".config/Code/GPUCache"
# ".config/Code/Service Worker/CacheStorage"
# ".config/Code/Service Worker/ScriptCache"
# ];
};
# Some filthy fucking shit below, be warned.
# Microsoft stores cache under .config/Code instead of .cache/Code like normal people.
# Sometimes a race condition is caused if the cache bind mounts are created before the config one.
# So we do this. Sorry.
# https://github.com/nix-community/impermanence/blob/27979f1c3a0d3b9617a3563e2839114ba7d48d3f/home-manager.nix#L238
systemd.user.services = let
configDirService = "bindMount-${sanitizeName (lib.strings.escapeShellArg (concatPaths [ "/persist${user.home}" configDir ]))}.service";
in
builtins.listToAttrs (builtins.map (dir: {
name = "bindMount-${sanitizeName (lib.strings.escapeShellArg (concatPaths [ "/cache${user.home}" dir ]))}";
value = {
Unit = {
Requires = [ configDirService ];
After = [ configDirService ];
};
};
}) cacheDirs);
};
}

View File

@@ -5,7 +5,7 @@
userSettings = {
"nix.enableLanguageServer" = true;
"nix.formatterPath" = "nixpkgs-fmt";
"nix.serverSettings" = {};
"nix.serverSettings" = { };
};
extensions = with pkgs; with vscode-extensions; [
jnoortheen.nix-ide