Update to work with latest NixOS

This commit is contained in:
Konstantin Nazarov 2024-08-19 23:52:14 +01:00
parent 4db7f63b04
commit e1b69b417b
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
3 changed files with 154 additions and 148 deletions

View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1684076341,
"narHash": "sha256-60pNoKP2opEnGoPGrVo43Vt433El4+BcSl0TS36qJgQ=",
"lastModified": 1724104367,
"narHash": "sha256-ZYT8DwJKW6UTUm1F0kSluOGNrpmCrwEWruhtmWDhiNM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1feac2b61756a5a4392a6cc5f5b510325312437d",
"rev": "dfd48cea67e78574522201471bccca03383e9987",
"type": "github"
},
"original": {

View file

@ -22,7 +22,7 @@
pkgs = import nixpkgs { inherit system; };
});
make_package = pkgs: pkgs.stdenv.mkDerivation {
make_package = pkgs: pkgs.stdenv.mkDerivation rec {
name = "q-sh";
src = self;
installPhase = ''
@ -32,27 +32,33 @@
echo "OUT " $out
'';
dontStrip = true;
nativeBuildInputs = [pkgs.makeWrapper];
wrapperPath = pkgs.lib.makeBinPath ( with pkgs; [
fzf
findutils
gnused
gawk
bc
pass
coreutils
wl-clipboard
xdg-utils
]
);
postFixup = ''
q-fixup() {
TOOL="$1"
PATH="$2"
${pkgs.findutils}/bin/find $out -type f -name 'q*' -exec ${pkgs.gnused}/bin/sed -i "s#ENV_$TOOL=.*#ENV_$TOOL=$PATH#g" {} +
}
q-fixup "fzf" "${pkgs.fzf}/bin/fzf"
q-fixup "find" "${pkgs.findutils}/bin/find"
q-fixup "sed" "${pkgs.gnused}/bin/sed"
q-fixup "awk" "${pkgs.gawk}/bin/awk"
q-fixup "bc" "${pkgs.bc}/bin/bc"
q-fixup "pass" "${pkgs.pass}/bin/pass"
q-fixup "cut" "${pkgs.coreutils}/bin/cut"
q-fixup "base64" "${pkgs.coreutils}/bin/base64"
q-fixup "cat" "${pkgs.coreutils}/bin/cat"
q-fixup "tac" "${pkgs.coreutils}/bin/tac"
q-fixup "sort" "${pkgs.coreutils}/bin/sort"
q-fixup "uniq" "${pkgs.coreutils}/bin/uniq"
q-fixup "wl_copy" "${pkgs.wl-clipboard}/bin/wl-copy"
q-fixup "xdg_open" "${pkgs.xdg-utils}/bin/xdg-open"
q-fixup "q" "$out/bin"
substituteInPlace $out/bin/q \
--replace 'ENV_q="''${0##*/}"' "ENV_q=$out/bin/q"
# Ensure all dependencies are in PATH
for fn in $out/bin/q*; do
echo "wrapping $fn"
wrapProgram $fn \
--prefix PATH : "${wrapperPath}"
done
'';
};
in

2
q
View file

@ -36,7 +36,7 @@ ENV_q=~/.config/q.sh
SELF=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)/$(basename -- "$0")")
if [[ -z "$Q_SCRIPT_DIR" ]]; then
Q_SCRIPT_DIR="$ENV_q"
Q_SCRIPT_DIR="$(dirname -- $SELF)"
fi
INDEX_FILE=~/.q.index