2 Commits

Author SHA1 Message Date
fd57c04419 zsh: migrate config to home-manager module
All checks were successful
Check flake / build-amd64-linux (push) Successful in 4m0s
2025-02-02 13:06:10 +00:00
84bbcdfa4b home-assistant: remove duplicate floorplan resource 2025-02-01 14:10:05 +00:00
10 changed files with 234 additions and 211 deletions

View File

@ -1,5 +1,8 @@
{ config, ... }:
{ config, pkgs, ... }:
let
streamrip = pkgs.callPackage ../../pkgs/streamrip/package.nix { };
in
{
imports = [
./hardware-configuration.nix
@ -53,6 +56,10 @@
};
};
environment.systemPackages = [
streamrip
];
modules = {
programs = {
dev = {

View File

@ -1,34 +0,0 @@
source $ZDOTDIR/config.zsh
if [ ! -d "$ZGEN_DIR" ]; then
echo "Installing jandamm/zgenom"
git clone https://github.com/jandamm/zgenom "$ZGEN_DIR"
fi
source $ZGEN_DIR/zgenom.zsh
zgenom autoupdate
if ! zgenom saved; then
echo "Initializing zgenom"
rm -f $ZDOTDIR/*.zwc(N) \
$XDG_CACHE_HOME/zsh/*(N) \
$ZGEN_INIT.zwc
zgenom load junegunn/fzf shell
zgenom load zdharma-continuum/fast-syntax-highlighting
zgenom load zsh-users/zsh-completions src
zgenom load zsh-users/zsh-history-substring-search
zgenom load softmoth/zsh-vim-mode
zgenom save
zgenom compile $ZDOTDIR
fi
## Bootstrap interactive sessions
if [[ $TERM != dumb ]]; then
autoload -Uz compinit && compinit -u -d $ZSH_CACHE/zcompdump
source $ZDOTDIR/keybinds.zsh
source $ZDOTDIR/completion.zsh
source $ZDOTDIR/aliases.zsh
fi

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Verbose file operations
alias \
cp="cp -iv" \
mv="mv -iv" \
rm="rm -v" \
mkdir="mkdir -v"
# Colorize commands
alias \
ls="ls -h --color=auto --group-directories-first"
# Abbreviations
alias \
e="$EDITOR" \
f="$FILE" \
g="git" \
m="neomutt" \
n="$FILE" \
v="$EDITOR"
# XDG fixes
alias \
mbsync="mbsync -c $XDG_CONFIG_HOME/isync/mbsyncrc -a"

View File

@ -1,6 +0,0 @@
fpath+=( $ZDOTDIR/completions )
# Don't offer history completion; we have fzf, C-r, and
# zsh-history-substring-search for that.
ZSH_AUTOSUGGEST_STRATEGY=(completion)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=30

View File

@ -1,99 +0,0 @@
####
## zsh configuration
####
## Colors
autoload -U colors && colors
## Completion
setopt HASH_LIST_ALL
unsetopt AUTO_NAME_DIRS
autoload -Uz compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files
## Directories
setopt AUTO_PUSHD
setopt CDABLE_VARS
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
setopt PUSHD_TO_HOME
unsetopt AUTO_CD
## Expansion and globbing
setopt EXTENDED_GLOB
unsetopt GLOB_DOTS
unsetopt NOMATCH
## History
HISTFILE="${XDG_DATA_HOME:-${HOME}/.local/share}/zsh/history"
HISTSIZE=1000000
SAVEHIST=1000000
[[ !( -f "${HISTFILE}" ) ]] && mkdir -p $(dirname ${HISTFILE})
setopt APPEND_HISTORY
setopt BANG_HIST
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_SAVE_NO_DUPS
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY_TIME
setopt SHARE_HISTORY
## I/O
setopt INTERACTIVE_COMMENTS
setopt MULTIOS
unsetopt CLOBBER
## Jobs
setopt LONG_LIST_JOBS
setopt AUTO_RESUME
unsetopt BG_NICE
unsetopt NOTIFY
unsetopt HUP
unsetopt CHECK_JOBS
## Shell emulation
setopt APPEND_CREATE
## Prompt
PS1="%B%{$fg[magenta]%}%~%{$reset_color%} $%b "
## Window title
precmd () { print -Pn "\e]0;%n@%m: %~\a" }
preexec () { print -Pn "\e]0;%n@%m: $1\a" }
## Vi mode
bindkey -v
export KEYTIMEOUT=1
## Zsh line editor
unsetopt BEEP
####
## Plugins
####
export ZGEN_AUTOLOAD_COMPINIT=0
# zsh-vim-mode
export MODE_INDICATOR=""
export MODE_CURSOR_VIINS="#b77ee0 blinking bar"
export MODE_CURSOR_REPLACE="$MODE_CURSOR_VIINS #ff3334"
export MODE_CURSOR_VICMD="#b77ee0 block"
export MODE_CURSOR_SEARCH="#e7c547 steady underline"
export MODE_CURSOR_VISUAL="$MODE_CURSOR_VICMD steady bar"
export MODE_CURSOR_VLINE="$MODE_CURSOR_VISUAL #54ced6"
# fzf
if (( $+commands[fd] )); then
export FZF_DEFAULT_OPTS="--reverse --ansi"
export FZF_DEFAULT_COMMAND="fd ."
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd -t d . $HOME"
fi

View File

@ -19,42 +19,137 @@ in
config = lib.mkIf cfg.enable {
users.defaultUserShell = pkgs.zsh;
programs.zsh = {
enable = true;
enableCompletion = true;
enableGlobalCompInit = false;
promptInit = "";
home.programs = {
zsh = {
enable = true;
autocd = true;
autosuggestion = {
enable = true;
strategy = [ "completion" ];
};
dotDir = ".config/zsh";
enableCompletion = true;
enableVteIntegration = true;
history = {
append = true;
extended = true;
ignoreAllDups = true;
ignoreDups = true;
ignoreSpace = true;
save = 1000000;
size = 1000000;
};
historySubstringSearch = {
enable = true;
};
initExtra = ''
## Directories
setopt AUTO_PUSHD
setopt CDABLE_VARS
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
setopt PUSHD_TO_HOME
## Expansion and globbing
setopt EXTENDED_GLOB
unsetopt GLOB_DOTS
unsetopt NOMATCH
## History
setopt BANG_HIST
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY_TIME
## I/O
setopt INTERACTIVE_COMMENTS
setopt MULTIOS
unsetopt CLOBBER
## Jobs
setopt LONG_LIST_JOBS
setopt AUTO_RESUME
unsetopt BG_NICE
unsetopt NOTIFY
unsetopt HUP
unsetopt CHECK_JOBS
## Shell emulation
setopt APPEND_CREATE
## Prompt
PS1="%B%{$fg[magenta]%}%~%{$reset_color%} $%b "
## Vi mode
bindkey -v
export KEYTIMEOUT=1
## Zsh line editor
unsetopt BEEP
'';
initExtraBeforeCompInit = ''
setopt HASH_LIST_ALL
'';
plugins = with pkgs; [
{
name = "fast-syntax-highlighting";
src = zsh-fast-syntax-highlighting;
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
}
{
name = "zsh-vi-mode";
src = zsh-vi-mode;
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh";
}
];
sessionVariables = {
MODE_INDICATOR = "";
MODE_CURSOR_VIINS = "#b77ee0 blinking bar";
MODE_CURSOR_REPLACE = "$MODE_CURSOR_VIINS #ff3334";
MODE_CURSOR_VICMD = "#b77ee0 block";
MODE_CURSOR_SEARCH = "#e7c547 steady underline";
MODE_CURSOR_VISUAL = "$MODE_CURSOR_VICMD steady bar";
MODE_CURSOR_VLINE = "$MODE_CURSOR_VISUAL #54ced6";
};
shellAliases = {
# Verbose file operations
cp = "cp -iv";
mv = "mv -iv";
rm = "rm -v";
mkdir = "mkdir -v";
# Colorize commands
ls = "ls -h --collor=auto --group-directories-first";
# Abbreviations
e = "$EDITOR";
f = "$FILE";
g = "git";
m = "neomutt";
n = "$FILE";
v = "$EDITOR";
};
};
fzf = {
enable = true;
enableZshIntegration = true;
package = pkgs.unstable.fzf;
};
};
user.packages = with pkgs; [
fd
unstable.fzf
jq
nix-zsh-completions
nnn
ripgrep
zsh
];
env = {
ZDOTDIR = "$XDG_CONFIG_HOME/zsh";
ZSH_CACHE = "$XDG_CACHE_HOME/zsh";
ZGEN_DIR = "$XDG_DATA_HOME/zgenom";
};
home.configFile = {
"zsh/.zshrc".source = ./.zshrc;
"zsh/aliases.zsh".source = ./aliases.zsh;
"zsh/completion.zsh".source = ./completion.zsh;
"zsh/config.zsh".source = ./config.zsh;
"zsh/keybinds.zsh".source = ./keybinds.zsh;
};
system.userActivationScripts.cleanupZgen = ''
rm -rf $ZDOTDIR/.*.zwc
rm -f $ZDOTDIR/.zcompdump
rm -rf $ZSH_CACHE
rm -fv $ZGEN_DIR/init.zsh{,.zwc}
'';
};
}

View File

@ -1,12 +0,0 @@
####
## Keybindings
####
stty stop undef
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
if (( $+commands[fzf] )); then
bindkey '^R' fzf-history-widget
fi

View File

@ -11,12 +11,6 @@ in
{
config = lib.mkIf cfg.enable {
services.home-assistant = {
config.lovelace.resources = [
{
url = "/local/nixos-lovelace-modules/floorplan.js";
type = "module";
}
];
customLovelaceModules = [
pkgs.lovelace-floorplan
];

View File

@ -0,0 +1,25 @@
From 18efb9b5c8e562b169425f6ba79977e52e8b91b9 Mon Sep 17 00:00:00 2001
From: Pavel Sobolev <paveloomm@gmail.com>
Date: Sat, 13 Jan 2024 12:49:45 +0000
Subject: [PATCH] Ensure the default config file is writable.
---
streamrip/config.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/streamrip/config.py b/streamrip/config.py
index 7ee2f57..88a5fef 100644
--- a/streamrip/config.py
+++ b/streamrip/config.py
@@ -378,6 +378,9 @@ def set_user_defaults(path: str, /):
"""Update the TOML file at the path with user-specific default values."""
shutil.copy(BLANK_CONFIG_PATH, path)
+ # Ensure the default config file is writable
+ os.chmod(path, 0o644)
+
with open(path) as f:
toml = parse(f.read())
toml["downloads"]["folder"] = DEFAULT_DOWNLOADS_FOLDER # type: ignore
--
2.42.0

View File

@ -0,0 +1,78 @@
{
lib,
python3Packages,
fetchFromGitHub,
ffmpeg,
}:
python3Packages.buildPythonApplication {
pname = "streamrip";
version = "2.0.7";
pyproject = true;
src = fetchFromGitHub {
owner = "nathom";
repo = "streamrip";
rev = "46b570dbb6f81d604cbaa3bfa379463e0a20a841";
hash = "sha256-LD99OjguaBnrQxCwmCeHvmBMq5aOfobwnMd5/aCRZW8=";
};
patches = [
./ensure-the-default-config-file-is-writable.patch
];
nativeBuildInputs = with python3Packages; [
poetry-core
];
propagatedBuildInputs = with python3Packages; [
aiodns
aiofiles
aiohttp
aiolimiter
appdirs
cleo
click-help-colors
deezer-py
m3u8
mutagen
pathvalidate
pillow
pycryptodomex
pytest-asyncio
pytest-mock
rich
simple-term-menu
tomlkit
tqdm
];
nativeCheckInputs = with python3Packages; [
pytestCheckHook
];
prePatch = ''
sed -i 's#aiofiles = ".*"#aiofiles = "*"#' pyproject.toml
sed -i 's#deezer-py = ".*"#deezer-py = "*"#' pyproject.toml
sed -i 's#m3u8 = ".*"#m3u8 = "*"#' pyproject.toml
sed -i 's#pathvalidate = ".*"#pathvalidate = "*"#' pyproject.toml
sed -i 's#Pillow = ".*"#Pillow = "*"#' pyproject.toml
sed -i 's#pytest-asyncio = ".*"#pytest-asyncio = "*"#' pyproject.toml
sed -i 's#tomlkit = ".*"#tomlkit = "*"#' pyproject.toml
sed -i 's#"ffmpeg"#"${lib.getBin ffmpeg}/bin/ffmpeg"#g' streamrip/client/downloadable.py
'';
preCheck = ''
export HOME=$(mktemp -d)
'';
meta = with lib; {
description = "Scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer";
homepage = "https://github.com/nathom/streamrip";
license = licenses.gpl3Only;
maintainers = with maintainers; [ paveloom ];
mainProgram = "rip";
};
}