2022-06-12 00:40:15 +00:00
|
|
|
{ lib
|
2022-06-12 00:54:29 +00:00
|
|
|
, pkgs
|
2022-08-19 08:50:51 +00:00
|
|
|
, resholve
|
2023-03-22 21:21:00 +00:00
|
|
|
, static-nix-shell
|
|
|
|
, symlinkJoin
|
2022-06-12 00:40:15 +00:00
|
|
|
}:
|
|
|
|
|
2023-03-22 21:21:00 +00:00
|
|
|
let
|
|
|
|
shell-scripts = resholve.mkDerivation {
|
|
|
|
# resholve documentation:
|
|
|
|
# - nix: https://github.com/nixos/nixpkgs/blob/master/pkgs/development/misc/resholve/README.md
|
|
|
|
# - generic: https://github.com/abathur/resholve
|
|
|
|
pname = "sane-scripts";
|
|
|
|
version = "0.1.0";
|
2022-06-12 00:40:15 +00:00
|
|
|
|
2023-03-22 21:21:00 +00:00
|
|
|
src = ./src;
|
2022-06-12 00:40:15 +00:00
|
|
|
|
2023-03-22 21:21:00 +00:00
|
|
|
solutions = {
|
|
|
|
default = {
|
|
|
|
# note: `scripts` refers to the store path here
|
|
|
|
scripts = [ "bin/*" ];
|
|
|
|
interpreter = "${pkgs.bash}/bin/bash";
|
|
|
|
inputs = with pkgs; [
|
|
|
|
# string is interpreted as relative path from @OUT@.
|
|
|
|
# this lets our scripts reference eachother.
|
|
|
|
# see: <https://github.com/abathur/resholve/issues/26>
|
|
|
|
"bin"
|
|
|
|
coreutils-full
|
|
|
|
file
|
|
|
|
findutils
|
|
|
|
gnugrep
|
|
|
|
gnused
|
|
|
|
gocryptfs
|
|
|
|
ifuse
|
|
|
|
inetutils
|
|
|
|
iwd
|
|
|
|
jq
|
|
|
|
oath-toolkit
|
|
|
|
openssh
|
|
|
|
openssl
|
2023-06-06 08:15:16 +00:00
|
|
|
nix-shell-scripts.ip-check
|
2023-03-22 21:21:00 +00:00
|
|
|
rmlint
|
|
|
|
rsync
|
|
|
|
ssh-to-age
|
|
|
|
sops
|
|
|
|
sudo
|
|
|
|
systemd
|
|
|
|
util-linux
|
|
|
|
which
|
2022-08-19 08:50:51 +00:00
|
|
|
];
|
2023-03-22 21:21:00 +00:00
|
|
|
keep = {
|
|
|
|
# we write here: keep it
|
|
|
|
"/tmp/rmlint.sh" = true;
|
|
|
|
# intentionally escapes (into user code)
|
|
|
|
"$external_cmd" = true;
|
|
|
|
"$maybe_sudo" = true;
|
|
|
|
};
|
|
|
|
fake = {
|
|
|
|
external = [
|
|
|
|
# https://github.com/abathur/resholve/issues/29
|
|
|
|
# "umount"
|
|
|
|
# "/run/wrappers/bin/sudo"
|
|
|
|
"sudo"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
fix = {
|
|
|
|
# this replaces umount with the non-setuid-wrapper umount.
|
|
|
|
# not sure if/where that lack of suid causes problems.
|
|
|
|
umount = true;
|
|
|
|
};
|
2023-04-24 10:02:24 +00:00
|
|
|
prologue = "${./resholve-prologue}";
|
2022-08-19 08:50:51 +00:00
|
|
|
|
2023-03-22 21:21:00 +00:00
|
|
|
# list of programs which *can* or *cannot* exec their arguments
|
|
|
|
execer = with pkgs; [
|
|
|
|
"cannot:${git}/bin/git"
|
|
|
|
"cannot:${gocryptfs}/bin/gocryptfs"
|
|
|
|
"cannot:${ifuse}/bin/ifuse"
|
|
|
|
"cannot:${iwd}/bin/iwctl"
|
|
|
|
"cannot:${oath-toolkit}/bin/oathtool"
|
|
|
|
"cannot:${openssh}/bin/ssh-keygen"
|
|
|
|
"cannot:${rmlint}/bin/rmlint"
|
|
|
|
"cannot:${rsync}/bin/rsync"
|
|
|
|
"cannot:${sops}/bin/sops"
|
|
|
|
"cannot:${ssh-to-age}/bin/ssh-to-age"
|
|
|
|
"cannot:${systemd}/bin/systemctl"
|
|
|
|
];
|
|
|
|
};
|
2022-08-19 08:50:51 +00:00
|
|
|
};
|
2022-06-12 00:40:15 +00:00
|
|
|
|
2023-05-27 09:57:09 +00:00
|
|
|
patchPhase =
|
|
|
|
let
|
|
|
|
rmPy = builtins.concatStringsSep
|
|
|
|
"\n"
|
2023-06-06 08:15:16 +00:00
|
|
|
(lib.mapAttrsToList (name: pkg: "rm ${pkg.pname}") nix-shell-scripts)
|
2023-05-27 09:57:09 +00:00
|
|
|
;
|
|
|
|
in ''
|
|
|
|
# remove python library files, and python binaries (those are packaged further below)
|
|
|
|
rm -rf lib/
|
|
|
|
${rmPy}
|
|
|
|
'';
|
2022-12-21 06:29:13 +00:00
|
|
|
|
2023-03-22 21:21:00 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp -R * $out/bin/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-06 08:15:16 +00:00
|
|
|
nix-shell-scripts = {
|
2023-05-19 19:48:52 +00:00
|
|
|
# anything added to this attrset gets symlink-joined into `sane-scripts`
|
2023-05-19 19:58:37 +00:00
|
|
|
backup-ls = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-backup-ls";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "duplicity" ];
|
|
|
|
};
|
|
|
|
backup-restore = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-backup-restore";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "duplicity" ];
|
|
|
|
};
|
2023-05-19 19:48:52 +00:00
|
|
|
bt-add = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-bt-add";
|
2023-04-20 08:00:59 +00:00
|
|
|
src = ./src;
|
2023-05-19 19:48:52 +00:00
|
|
|
pkgs = [ "transmission" ];
|
2023-04-20 08:00:59 +00:00
|
|
|
};
|
2023-05-13 10:31:48 +00:00
|
|
|
bt-rm = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-bt-rm";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "transmission" ];
|
|
|
|
};
|
2023-05-19 19:48:52 +00:00
|
|
|
bt-search = static-nix-shell.mkPython3Bin {
|
|
|
|
pname = "sane-bt-search";
|
|
|
|
src = ./src;
|
|
|
|
pyPkgs = [ "natsort" "requests" ];
|
|
|
|
};
|
2023-05-19 19:52:44 +00:00
|
|
|
bt-show = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-bt-show";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "transmission" ];
|
|
|
|
};
|
2023-06-06 08:04:11 +00:00
|
|
|
deadlines = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-deadlines";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "coreutils-full" ];
|
|
|
|
};
|
2023-06-06 08:07:42 +00:00
|
|
|
dev-cargo-loop = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-dev-cargo-loop";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "inotify-tools" "ncurses" ];
|
2023-06-06 08:09:37 +00:00
|
|
|
};
|
|
|
|
find-dotfiles = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-find-dotfiles";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "findutils" ];
|
2023-06-06 08:07:42 +00:00
|
|
|
};
|
2023-06-06 08:10:31 +00:00
|
|
|
git-init = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-git-init";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "git" ];
|
|
|
|
};
|
2023-06-06 08:12:42 +00:00
|
|
|
ip-check = static-nix-shell.mkBash {
|
|
|
|
pname = "sane-ip-check";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "curl" "gnugrep" ];
|
|
|
|
};
|
2023-05-26 22:39:32 +00:00
|
|
|
ip-check-upnp = static-nix-shell.mkPython3Bin {
|
|
|
|
pname = "sane-ip-check-upnp";
|
|
|
|
src = ./src;
|
|
|
|
pkgs = [ "miniupnpc" ];
|
2023-05-27 09:57:09 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/bin/lib
|
|
|
|
cp -R lib/* $out/bin/lib/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
ip-port-forward = static-nix-shell.mkPython3Bin {
|
|
|
|
pname = "sane-ip-port-forward";
|
|
|
|
src = ./src;
|
2023-05-27 23:27:36 +00:00
|
|
|
pkgs = [ "inetutils" "miniupnpc" ];
|
2023-05-27 09:57:09 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/bin/lib
|
|
|
|
cp -R lib/* $out/bin/lib/
|
|
|
|
'';
|
2023-05-26 22:39:32 +00:00
|
|
|
};
|
2023-04-20 08:00:59 +00:00
|
|
|
ip-reconnect = static-nix-shell.mkPython3Bin {
|
|
|
|
pname = "sane-ip-reconnect";
|
|
|
|
src = ./src;
|
|
|
|
};
|
2023-06-06 08:15:16 +00:00
|
|
|
reclaim-boot-space = static-nix-shell.mkPython3Bin {
|
|
|
|
pname = "sane-reclaim-boot-space";
|
|
|
|
src = ./src;
|
|
|
|
};
|
2023-03-22 21:21:00 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
symlinkJoin {
|
|
|
|
name = "sane-scripts";
|
2023-06-06 08:15:16 +00:00
|
|
|
paths = [ shell-scripts ] ++ lib.attrValues nix-shell-scripts;
|
2022-06-12 00:40:15 +00:00
|
|
|
meta = {
|
|
|
|
description = "collection of scripts associated with uninsane systems";
|
|
|
|
homepage = "https://git.uninsane.org";
|
|
|
|
platforms = lib.platforms.all;
|
|
|
|
};
|
|
|
|
}
|