diff options
Diffstat (limited to 'modules/scripts')
| -rw-r--r-- | modules/scripts/default.nix | 86 | ||||
| -rw-r--r-- | modules/scripts/file-preview.sh | 21 | ||||
| -rw-r--r-- | modules/scripts/fzf-launcher.sh | 2 |
3 files changed, 68 insertions, 41 deletions
diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix index ffde799..a2d9e1a 100644 --- a/modules/scripts/default.nix +++ b/modules/scripts/default.nix @@ -6,8 +6,7 @@ ... }: let - shell = - if config.terminal.zsh.enable then (lib.getExe config.terminal.zsh.package) else "/usr/bin/env sh"; + shell = pkgs.runtimeShell; mkScript = name: path: env: deps: @@ -24,16 +23,20 @@ let ''; }; in - pkgs.symlinkJoin { - name = name; - paths = [ wrappedScript ] ++ deps; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' + pkgs.runCommand name + { + name = name; + nativeBuildInputs = [ pkgs.makeWrapper ]; + meta.mainProgram = name; + } + '' + mkdir -p $out/bin + cp ${wrappedScript}/bin/${name} $out/bin/${name} + chmod +x $out/bin/${name} + wrapProgram $out/bin/${name} \ --prefix PATH : ${lib.makeBinPath deps} ''; - meta.mainProgram = name; - }; # Script definitions: { path, env?, deps?, conditions? } # condition: attrset of { option (string path), value (expected value) } @@ -60,22 +63,26 @@ let config.terminal.bat.package config.media.ffmpeg.package config.file-management.ouch.package + pkgs.coreutils pkgs.file + pkgs.fontconfig pkgs.librsvg + pkgs.antiword + pkgs.pandoc pkgs.poppler-utils + pkgs.util-linux ]; conditions = [ { - option = "media.ffmpeg.enable"; + option = "terminal.kitty.enable"; value = true; } { - option = "file-management.ouch.enable"; + option = "media.ffmpeg.enable"; value = true; } { - # not a dependency - option = "office.zathura.enable"; + option = "file-management.ouch.enable"; value = true; } { @@ -101,26 +108,30 @@ let deps = [ config.terminal.fzf.package pkgs.util-linux - config.terminal.zsh.package ]; conditions = [ { option = "terminal.fzf.enable"; value = true; } - { - option = "terminal.zsh.enable"; - value = true; - } ]; }; i3-keybindings = { path = ./i3-keybindings.sh; + deps = [ + pkgs.coreutils + pkgs.gawk + pkgs.ncurses + ]; conditions = [ { option = "desktop.enable"; value = true; } + { + option = "terminal.less.enable"; + value = true; + } ]; }; screen-recording = { @@ -147,6 +158,7 @@ let config.system.nvtop.package config.terminal.tmux.package config.terminal.kitty.package + pkgs.bash ]; conditions = [ { @@ -175,6 +187,10 @@ let deps = [ config.terminal.fzf.package config.security.openvpn.package + pkgs.coreutils + pkgs.findutils + pkgs.gnugrep + pkgs.gnused ]; conditions = [ { @@ -200,6 +216,10 @@ let path = ./neomutt-sync.sh; deps = [ pkgs.dialog + pkgs.coreutils + pkgs.gawk + pkgs.gnused + pkgs.util-linux config.programs.mbsync.package config.programs.notmuch.package ]; @@ -299,17 +319,25 @@ in }; }; - assertions = lib.concatLists ( - lib.mapAttrsToList ( - name: def: - map (cond: { - assertion = - !config.scripts.${name}.enable - || lib.attrByPath (lib.splitString "." cond.option) false config == cond.value; - message = "scripts.${name} is enabled but requires `${cond.option} = ${builtins.toJSON cond.value}`."; - }) (def.conditions or [ ]) - ) scriptDefs - ); + assertions = + lib.concatLists ( + lib.mapAttrsToList ( + name: def: + map (cond: { + assertion = + !config.scripts.${name}.enable + || lib.attrByPath (lib.splitString "." cond.option) false config == cond.value; + message = "scripts.${name} is enabled but requires `${cond.option} = ${builtins.toJSON cond.value}`."; + }) (def.conditions or [ ]) + ) scriptDefs + ) + ++ lib.mapAttrsToList (name: _: { + assertion = + !config.scripts.${name}.enable + || !config.scripts.${name}.desktop.enable + || config.terminal.kitty.enable; + message = "scripts.${name}.desktop.enable requires terminal.kitty.enable because desktop entries launch scripts in kitty."; + }) scriptDefs; home.packages = [ pkgs.file diff --git a/modules/scripts/file-preview.sh b/modules/scripts/file-preview.sh index fc07fe1..047252d 100644 --- a/modules/scripts/file-preview.sh +++ b/modules/scripts/file-preview.sh @@ -99,17 +99,16 @@ case "$MIMETYPE" in [ -s "$TMP_IMG" ] && render_image "$TMP_IMG" ;; - # --- OFFICE --- - application/vnd.openxmlformats-officedocument.*|application/msword|application/vnd.oasis.opendocument.*) - TMP_IMG="$TMP_DIR/doc-${INODE}.png" - if [ ! -f "$TMP_IMG" ]; then - libreoffice --headless --convert-to pdf --outdir "$TMP_DIR" "$FILE_PATH" >/dev/null 2>&1 - PDF_VER="${TMP_DIR}/$(basename "${FILE_PATH%.*}").pdf" - if [ -f "$PDF_VER" ]; then - pdftoppm -f 1 -l 1 -png -singlefile "$PDF_VER" "${TMP_IMG%.png}" >/dev/null 2>&1 - fi - fi - render_image "$TMP_IMG" + # --- OFFICE DOCUMENTS --- + # Extract text in the terminal instead of pulling in a graphical office suite. + application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text) + pandoc --to plain "$FILE_PATH" 2>/dev/null + exit 0 + ;; + + application/msword) + antiword "$FILE_PATH" 2>/dev/null + exit 0 ;; # --- ARCHIVES --- diff --git a/modules/scripts/fzf-launcher.sh b/modules/scripts/fzf-launcher.sh index 1d7f968..5ae3d95 100644 --- a/modules/scripts/fzf-launcher.sh +++ b/modules/scripts/fzf-launcher.sh @@ -10,7 +10,7 @@ entries="" for dir in "${DIRS[@]}"; do [[ -d "$dir" ]] || continue - setopt nullglob + shopt -s nullglob for f in "$dir"/*.desktop; do [[ -f "$f" ]] || continue |
