Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-04-25 17:35:29 +03:00
parent 8b2cebae3b
commit 855edc83f4
25 changed files with 178 additions and 762 deletions

View File

@@ -13,6 +13,6 @@
];
home-manager.sharedModules = [
{ programs.zsh.initExtra = builtins.readFile ./backup.completion.zsh; }
{ programs.zsh.initContent = builtins.readFile ./backup.completion.zsh; }
];
}

View File

@@ -16,6 +16,6 @@
];
home-manager.sharedModules = [
{ programs.zsh.initExtra = builtins.readFile ./install.completion.zsh; }
{ programs.zsh.initContent = builtins.readFile ./install.completion.zsh; }
];
}

View File

@@ -49,7 +49,7 @@
};
zsh = {
initExtra = ''
initContent = ''
kubeswitch() {
local target="$HOME/.kube/$1"
local config="$HOME/.kube/config"

View File

@@ -12,7 +12,7 @@
home-manager.users.${user}.programs.zsh = {
shellAliases.nd = "nix-develop";
initExtra =
initContent =
let
devShells = lib.strings.concatStringsSep " " (
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}

View File

@@ -10,97 +10,19 @@
...
}:
{
home-manager.users.${user} = {
programs = {
direnv = {
enable = true;
silent = true;
nix-direnv.enable = true;
enableZshIntegration = true;
home-manager.users.${user}.programs = {
direnv = {
enable = true;
silent = true;
nix-direnv.enable = true;
enableZshIntegration = true;
config = {
global.warn_timeout = 0;
};
zsh = {
shellAliases.nde = "nix-direnv";
initExtra =
let
devShells = lib.strings.concatStringsSep " " (
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
);
in
''
nix-direnv() {
local devshell=""
local hide=false
while getopts "s:h" opt; do
case $opt in
s)
devshell="$OPTARG"
;;
h)
hide=true
;;
*)
echo "Usage: nix-direnv [-s <devshell>] [-h]"
return 1
;;
esac
done
if [[ -z "$devshell" ]]; then
if "$hide"; then
echo "use flake path:." > .envrc;
else
echo "use flake" > .envrc;
fi
if [ ! -f flake.nix ]; then
cp "${../nix-develop/template.nix}" flake.nix
chmod 755 flake.nix
fi
if [ ! -f treefmt.nix ]; then
cp "${../nix-develop/treefmt.nix}" treefmt.nix
chmod 755 treefmt.nix
fi
else
echo "use flake self#$devshell" > .envrc
fi
if "$hide" && git rev-parse --is-inside-work-tree &>/dev/null; then
local top
top="$(git rev-parse --show-toplevel)"
if ! grep -q "^\.envrc$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "$(realpath --relative-to="$top" .envrc)" >> "$top/.git/info/exclude"; fi
if [ -z "$devshell" ]; then
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
if ! grep -q "^treefmt.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "treefmt.nix" >> "$top/.git/info/exclude"; fi
fi
fi
direnv allow
}
_nix-direnv_completion() {
local options=(
'-s[Dev shell from root flake]:shell:(${devShells})'
'-h[Hide .envrc and flake.nix in git]'
)
_arguments -s $options
}
compdef _nix-direnv_completion nix-direnv
'';
p10k.extraRightPromptElements = [ "direnv" ];
};
};
# https://github.com/direnv/direnv/wiki/Customizing-cache-location
xdg.configFile = {
"direnv/direnvrc".text = ''
# https://github.com/direnv/direnv/wiki/Customizing-cache-location
stdlib = ''
declare -A direnv_layout_dirs
direnv_layout_dir() {
local hash path
@@ -111,10 +33,84 @@
)}"
}
'';
};
"direnv/direnv.toml".source = (
(pkgs.formats.toml { }).generate "direnv.toml" { global.warn_timeout = 0; }
);
zsh = {
shellAliases.nde = "nix-direnv";
initContent =
let
devShells = lib.strings.concatStringsSep " " (
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
);
in
''
nix-direnv() {
local devshell=""
local hide=false
while getopts "s:h" opt; do
case $opt in
s)
devshell="$OPTARG"
;;
h)
hide=true
;;
*)
echo "Usage: nix-direnv [-s <devshell>] [-h]"
return 1
;;
esac
done
if [[ -z "$devshell" ]]; then
if "$hide"; then
echo "use flake path:." > .envrc;
else
echo "use flake" > .envrc;
fi
if [ ! -f flake.nix ]; then
cp "${../nix-develop/template.nix}" flake.nix
chmod 755 flake.nix
fi
if [ ! -f treefmt.nix ]; then
cp "${../nix-develop/treefmt.nix}" treefmt.nix
chmod 755 treefmt.nix
fi
else
echo "use flake self#$devshell" > .envrc
fi
if "$hide" && git rev-parse --is-inside-work-tree &>/dev/null; then
local top
top="$(git rev-parse --show-toplevel)"
if ! grep -q "^\.envrc$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "$(realpath --relative-to="$top" .envrc)" >> "$top/.git/info/exclude"; fi
if [ -z "$devshell" ]; then
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
if ! grep -q "^treefmt.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "treefmt.nix" >> "$top/.git/info/exclude"; fi
fi
fi
direnv allow
}
_nix-direnv_completion() {
local options=(
'-s[Dev shell from root flake]:shell:(${devShells})'
'-h[Hide .envrc and flake.nix in git]'
)
_arguments -s $options
}
compdef _nix-direnv_completion nix-direnv
'';
p10k.extraRightPromptElements = [ "direnv" ];
};
};

View File

@@ -33,7 +33,7 @@
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
];
initExtra = ''
initContent = ''
source ${./.p10k.zsh}
'';
};

View File

@@ -18,7 +18,7 @@ in
with lib;
with cfg;
{
initExtra = ''
initContent = ''
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " p10k.extraRightPromptElements})
'';
};

View File

@@ -140,13 +140,6 @@ in
showNewVersionNotification = false;
};
}
{
pkg = selfPkgs.obsidian-plugin-folder-note;
options = {
folderNoteHide = false;
folderNoteStrInit = "";
};
}
{
pkg = selfPkgs.obsidian-plugin-kanban;
options = {

View File

@@ -14,6 +14,14 @@ let
hmConfig = config.home-manager.users.${user};
in
{
nixpkgs.overlays = [
(final: prev: {
spicetify-cli = prev.spicetify-cli.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [ ./user-colors.patch ];
});
})
];
networking.firewall = {
allowedTCPPorts = [ 57621 ];
allowedUDPPorts = [ 5353 ];

View File

@@ -0,0 +1,31 @@
diff --git a/src/apply/apply.go b/src/apply/apply.go
index 47f1346..47badab 100644
--- a/src/apply/apply.go
+++ b/src/apply/apply.go
@@ -2,6 +2,7 @@ package apply
import (
"fmt"
+ "errors"
"os"
"path/filepath"
"strings"
@@ -65,10 +66,17 @@ func AdditionalOptions(appsFolderPath string, flags Flag) {
// To not use custom css, set `themeFolder` to blank string
// To use default color scheme, set `scheme` to `nil`
func UserCSS(appsFolderPath, themeFolder string, scheme map[string]string) {
+ colorsSrc := os.Getenv("COLORS_CSS_PATH")
colorsDest := filepath.Join(appsFolderPath, "xpui", "colors.css")
- if err := os.WriteFile(colorsDest, []byte(getColorCSS(scheme)), 0700); err != nil {
+
+ if len(colorsSrc) == 0 {
+ utils.Fatal(errors.New("COLORS_CSS_PATH environment variable is not set"))
+ }
+
+ if err := os.Symlink(colorsSrc, colorsDest); err != nil {
utils.Fatal(err)
}
+
cssDest := filepath.Join(appsFolderPath, "xpui", "user.css")
if err := os.WriteFile(cssDest, []byte(getUserCSS(themeFolder)), 0700); err != nil {
utils.Fatal(err)

View File

@@ -535,6 +535,6 @@ in
}
);
programs.zsh.initExtra = builtins.readFile ./theme.completion.zsh;
programs.zsh.initContent = builtins.readFile ./theme.completion.zsh;
};
}