sane-scripts: port sane-sync-from-iphone to nix-shell

This commit is contained in:
Colin 2023-06-07 07:20:27 +00:00
parent b9cc581736
commit 855a66499f
3 changed files with 19 additions and 1 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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: