From adfc010f6574bc6bf1d39b712ba57fe1bfc97667 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 2 Aug 2021 03:13:44 -0600 Subject: [PATCH] [NixOS] Add functions autoload --- dotfiles/lib/functions/get_cols | 8 +++++++ dotfiles/lib/get_cols.awk | 1 + nixos/environment.nix | 42 +++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100755 dotfiles/lib/functions/get_cols create mode 100644 nixos/environment.nix diff --git a/dotfiles/lib/functions/get_cols b/dotfiles/lib/functions/get_cols new file mode 100755 index 00000000..dedac6bf --- /dev/null +++ b/dotfiles/lib/functions/get_cols @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +function get_cols { + FS="${FS:- }" + gawk -f "$HOME/.lib/get_cols.awk" -v "cols=$*" -v "FS=$FS" +} + +get_cols "$@" diff --git a/dotfiles/lib/get_cols.awk b/dotfiles/lib/get_cols.awk index ceb3c463..eb68fcee 100755 --- a/dotfiles/lib/get_cols.awk +++ b/dotfiles/lib/get_cols.awk @@ -1,4 +1,5 @@ #!/usr/bin/env gawk -f + BEGIN { column_count=split(cols,column_numbers," "); } diff --git a/nixos/environment.nix b/nixos/environment.nix new file mode 100644 index 00000000..ef633be6 --- /dev/null +++ b/nixos/environment.nix @@ -0,0 +1,42 @@ +{ config, pkgs, options, lib, ... }: +with lib; +{ + options = { + dotfiles-directory = mkOption { + type = types.str; + default = "/home/imalison/dotfiles"; + }; + }; + + config = let libDir = "${config.dotfiles-directory}/dotfiles/lib"; + in { + # Shell configuration + programs.zsh = { + enable = true; + syntaxHighlighting = { + enable = true; + }; + ohMyZsh = { + enable = true; + plugins = [ "git" "sudo" "pip" ]; + }; + spaceship-prompt.enable = true; + shellInit = '' + fpath+="${libDir}/functions" + for file in "${libDir}/functions/"* + do + autoload "''${file##*/}" + done + ''; + }; + + environment = { + homeBinInPath = true; + localBinInPath = true; + extraInit = '' + export PATH="${libDir}/bin:$PATH" + export PATH="${libDir}/functions:$PATH" + ''; + }; + }; +}