From 6558b597db2da1a78f5fda5c0da4ca6d32c83e6f Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Wed, 5 Jan 2022 10:52:59 +0100 Subject: [PATCH] Add bin scripts --- bins/default.nix | 12 ++++++++++++ bins/scripts/calculate-nix-path | 8 ++++++++ home.nix | 3 +++ programs/fish.nix | 4 ++-- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 bins/default.nix create mode 100755 bins/scripts/calculate-nix-path diff --git a/bins/default.nix b/bins/default.nix new file mode 100644 index 0000000..ff62623 --- /dev/null +++ b/bins/default.nix @@ -0,0 +1,12 @@ +{ config, ... }: + +let + user-bin-directory = "${config.home.homeDirectory}/.bin"; +in +{ + home.file."${user-bin-directory}" = { + source = ./scripts; + recursive = true; + executable = true; + }; +} diff --git a/bins/scripts/calculate-nix-path b/bins/scripts/calculate-nix-path new file mode 100755 index 0000000..cbd3885 --- /dev/null +++ b/bins/scripts/calculate-nix-path @@ -0,0 +1,8 @@ +#!/bin/sh + +mkdir -p "$HOME/.cache/fish" + +nix flake metadata "$HOME/.config/nixpkgs" --json 2>/dev/null | \ + jq -r '.locks.nodes.nixpkgs.locked | "\(.type):\(.owner)/\(.repo)/\(.rev)"' | \ + xargs -I {} nix flake metadata {} --json | \ + jq -r '. | "nixpkgs=\(.path)"' >"$HOME/.cache/fish/nix_path_value" diff --git a/home.nix b/home.nix index 4a2aba7..55f00cd 100644 --- a/home.nix +++ b/home.nix @@ -16,6 +16,8 @@ ./programs/jq.nix ./config/yt-dlp.nix + + ./bins ]; home = { @@ -40,6 +42,7 @@ qemu ripgrep rtmpdump + streamlink tokei wget xz diff --git a/programs/fish.nix b/programs/fish.nix index c8ced68..d94594d 100644 --- a/programs/fish.nix +++ b/programs/fish.nix @@ -78,8 +78,8 @@ fenv source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh end - if test -d "$HOME/bin" - set -gx PATH "$HOME/bin" $PATH + if test -d "$HOME/.bin" + set -gx PATH "$HOME/.bin" $PATH end for app_path in \