From 855a66499f2e6734984fd5ae2499eba30a5068e6 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 7 Jun 2023 07:20:27 +0000 Subject: [PATCH] sane-scripts: port sane-sync-from-iphone to nix-shell --- pkgs/additional/sane-scripts/default.nix | 5 +++++ .../sane-scripts/src/sane-sync-from-iphone | 3 ++- pkgs/additional/static-nix-shell/default.nix | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/additional/sane-scripts/default.nix b/pkgs/additional/sane-scripts/default.nix index 4ee5677f..359d3774 100644 --- a/pkgs/additional/sane-scripts/default.nix +++ b/pkgs/additional/sane-scripts/default.nix @@ -271,6 +271,11 @@ let src = ./src; pkgs = [ "coreutils-full" ]; }; + sync-from-iphone = static-nix-shell.mkZsh { + pname = "sane-sync-from-iphone"; + src = ./src; + pkgs = [ "coreutils-full" "ifuse" "rsync" ]; + }; }; in symlinkJoin { diff --git a/pkgs/additional/sane-scripts/src/sane-sync-from-iphone b/pkgs/additional/sane-scripts/src/sane-sync-from-iphone index 61d46592..515a1fdb 100755 --- a/pkgs/additional/sane-scripts/src/sane-sync-from-iphone +++ b/pkgs/additional/sane-scripts/src/sane-sync-from-iphone @@ -1,4 +1,5 @@ -#!/usr/bin/env zsh +#!/usr/bin/env nix-shell +#!nix-shell -i zsh -p coreutils-full -p ifuse -p rsync # this really does need zsh because bash `test -e` behaves differently set -ex diff --git a/pkgs/additional/static-nix-shell/default.nix b/pkgs/additional/static-nix-shell/default.nix index 2e7a936e..c9c86bc7 100644 --- a/pkgs/additional/static-nix-shell/default.nix +++ b/pkgs/additional/static-nix-shell/default.nix @@ -82,6 +82,18 @@ in rec { } // (removeAttrs attrs [ "pkgs" ]) ); + # `mkShell` specialization for `nix-shell -i zsh` scripts. + mkZsh = { pname, pkgs ? {}, srcPath ? pname, ...}@attrs: + let + pkgsAsAttrs = pkgsToAttrs "" pkgs' pkgs; + pkgsEnv = attrValues pkgsAsAttrs; + pkgExprs = attrNames pkgsAsAttrs; + in mkShell ({ + inherit pkgsEnv pkgExprs; + interpreter = "${pkgs'.zsh}/bin/zsh"; + } // (removeAttrs attrs [ "pkgs" ]) + ); + # `mkShell` specialization for invocations of `nix-shell -p "python3.withPackages (...)"` # pyPkgs argument is parsed the same as pkgs, except that names are assumed to be relative to `"ps"` if specified in list form. mkPython3Bin = { pname, pkgs ? {}, pyPkgs ? {}, srcPath ? pname, ... }@attrs: