home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit d8c1b33c92898431dc2460d51463868966279a2e
parent 6d5f8872a4fdce67068834721563174974957f9e
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Fri, 31 Aug 2018 19:32:38 +0200

Make nix aliases a bit less reduntant…

… playing with the fish "language", I came up with this small
script. This allows me to define new aliases really quickly without
any copy/paste.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mfish/nix-aliases.fish | 47++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/fish/nix-aliases.fish b/fish/nix-aliases.fish @@ -1,27 +1,32 @@ -function mr - nix run nixpkgs.mr -c mr $argv +function _def_nix_run_aliases + set -l stable mr sshfs wakeonlan:python36Packages.wakeonlan lspci:pciutils lsusb:usbutils beet:beets + set -l unstable op:1password update-desktop-database:destkop-file-utils + for s in $stable + _nix_run_package $s + end + for s in $unstable + _nix_run_package $s "-f ~/.config/nixpkgs/channels.nix" + end end -function wakeonlan - nix run nixpkgs.python36Packages.wakeonlan -c wakeonlan $argv +function _nix_run_package + set -l s $argv[1] + set -l package (string split ":" $s) + switch (count $package) + case 1 + _nix_run $s $s $argv[2] + case 2 + _nix_run $package[1] $package[2] $argv[2] + end end -function op - nix run -f ~/.config/nixpkgs/channels.nix unstable.1password -c op $argv +function _nix_run + set -l c $argv[1] + set -l p $argv[2] + set -l extra $argv[3] + function $c --inherit-variable c --inherit-variable p --inherit-variable extra + nix run $extra "nixpkgs.$p" -c $c $argv + end end -function update-desktop-database - nix run nixpkgs.desktop-file-utils -c update-desktop-database $argv -end - -function sshfs - nix run nixpkgs.sshfs -c sshfs $argv -end - -function lspci - nix run nixpkgs.pciutils -c lspci $argv -end - -function lsusb - nix run nixpkgs.usbutils -c lsusb $argv -end +_def_nix_run_aliases