From 60f1235848d4546d334214de64fbcefd09ff9fdf Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Sun, 24 Jul 2022 13:22:49 -0400 Subject: [PATCH] Add shell aliases --- TODO.md | 10 +--------- common/default.nix | 28 ++-------------------------- common/shell.nix | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 common/shell.nix diff --git a/TODO.md b/TODO.md index 5c4b820..550d0ee 100644 --- a/TODO.md +++ b/TODO.md @@ -13,6 +13,7 @@ - Format everything here using nixfmt - Cleanup the line between hardware-configuration.nix and configuration.nix in machine config - CI https://gvolpe.com/blog/nixos-binary-cache-ci/ +- remove `options.currentSystem` ### NAS - helios64 extra led lights @@ -28,15 +29,6 @@ - just need a kernel module? https://github.com/firestack/bcachefs-tools-flake/blob/kf/dev/mvp/nixos/module/bcachefs.nix#L40 ### Shell Comands - -- myip = dig +short myip.opendns.com @resolver1.opendns.com - -#### https://linuxreviews.org/HOWTO_Test_Disk_I/O_Performance - -- seq read = `fio --name TEST --eta-newline=5s --filename=temp.file --rw=read --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting` -- seq write = `fio --name TEST --eta-newline=5s --filename=temp.file --rw=write --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting` -- random read = `fio --name TEST --eta-newline=5s --filename=temp.file --rw=randread --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=32 --runtime=60 --group_reporting` -- random write = `fio --name TEST --eta-newline=5s --filename=temp.file --rw=randrw --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=1 --runtime=60 --group_reporting` - tailexitnode = `sudo tailscale up --exit-node= --exit-node-allow-lan-access=true` ### Services diff --git a/common/default.nix b/common/default.nix index a2d652b..7850365 100644 --- a/common/default.nix +++ b/common/default.nix @@ -1,11 +1,10 @@ { config, pkgs, ... }: -let - nix-locate = config.inputs.nix-locate.defaultPackage.${config.currentSystem}; -in { +{ imports = [ ./flakes.nix ./auto-update.nix + ./shell.nix ./network ./boot ./server @@ -43,7 +42,6 @@ in { micro helix lm_sensors - nix-locate ]; nixpkgs.config.allowUnfree = true; @@ -64,28 +62,6 @@ in { nix.gc.automatic = true; - programs.command-not-found.enable = false; - - programs.fish = { - enable = true; - - shellInit = let - wrapper = pkgs.writeScript "command-not-found" '' - #!${pkgs.bash}/bin/bash - source ${nix-locate}/etc/profile.d/command-not-found.sh - command_not_found_handle "$@" - ''; - in '' - # use nix-locate for command-not-found functionality - function __fish_command_not_found_handler --on-event fish_command_not_found - ${wrapper} $argv - end - - # disable annoying fish shell greeting - set fish_greeting - ''; - }; - security.acme.acceptTerms = true; security.acme.defaults.email = "zuckerberg@neet.dev"; } diff --git a/common/shell.nix b/common/shell.nix new file mode 100644 index 0000000..88eb47b --- /dev/null +++ b/common/shell.nix @@ -0,0 +1,46 @@ +{ config, pkgs, ... }: + +# Improvements to the default shell +# - use nix-locate for command-not-found +# - disable fish's annoying greeting message +# - add some handy shell commands + +let + nix-locate = config.inputs.nix-locate.defaultPackage.${config.currentSystem}; +in { + programs.command-not-found.enable = false; + + environment.systemPackages = [ + nix-locate + ]; + + programs.fish = { + enable = true; + + shellInit = let + wrapper = pkgs.writeScript "command-not-found" '' + #!${pkgs.bash}/bin/bash + source ${nix-locate}/etc/profile.d/command-not-found.sh + command_not_found_handle "$@" + ''; + in '' + # use nix-locate for command-not-found functionality + function __fish_command_not_found_handler --on-event fish_command_not_found + ${wrapper} $argv + end + + # disable annoying fish shell greeting + set fish_greeting + ''; + }; + + environment.shellAliases = { + myip = "dig +short myip.opendns.com @resolver1.opendns.com"; + + # https://linuxreviews.org/HOWTO_Test_Disk_I/O_Performance + io_seq_read = "nix run nixpkgs#fio -- --name TEST --eta-newline=5s --filename=temp.file --rw=read --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting; rm temp.file"; + io_seq_write = "nix run nixpkgs#fio -- --name TEST --eta-newline=5s --filename=temp.file --rw=write --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting; rm temp.file"; + io_rand_read = "nix run nixpkgs#fio -- --name TEST --eta-newline=5s --filename=temp.file --rw=randread --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=32 --runtime=60 --group_reporting; rm temp.file"; + io_rand_write = "nix run nixpkgs#fio -- --name TEST --eta-newline=5s --filename=temp.file --rw=randrw --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=1 --runtime=60 --group_reporting; rm temp.file"; + }; +} \ No newline at end of file