Add nu-shell functions
This commit is contained in:
@@ -38,12 +38,6 @@ in
|
|||||||
path add /run/current-system/sw/bin
|
path add /run/current-system/sw/bin
|
||||||
path add ${config.home.homeDirectory}/.nix-profile/bin
|
path add ${config.home.homeDirectory}/.nix-profile/bin
|
||||||
|
|
||||||
def --env unlock [] {
|
|
||||||
if "BW_SESSION" not-in $env {
|
|
||||||
$env.BW_SESSION = ^bw unlock --raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def --env vpn [] {
|
def --env vpn [] {
|
||||||
unlock
|
unlock
|
||||||
let username = ^bw get username f7351f9c-b25b-4317-8352-affc00da4644
|
let username = ^bw get username f7351f9c-b25b-4317-8352-affc00da4644
|
||||||
@@ -52,33 +46,7 @@ in
|
|||||||
osascript ${vpn} $username $"($password)($otp)"
|
osascript ${vpn} $username $"($password)($otp)"
|
||||||
}
|
}
|
||||||
|
|
||||||
def rebuild [] {
|
source ${./nushell/functions.nu}
|
||||||
if (uname | get operating-system) == "Darwin" {
|
|
||||||
sudo darwin-rebuild switch
|
|
||||||
} else {
|
|
||||||
let hostname = uname | get nodename
|
|
||||||
let build = ^nom build $"/etc/nixos#nixosConfigurations.($hostname).config.system.build.toplevel" | complete
|
|
||||||
if build.exit_code == 0 {
|
|
||||||
nvd diff /run/current-system result
|
|
||||||
sudo nixos-rebuild switch
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def deploy [ $host: string, $build: string = "" ] {
|
|
||||||
mut buildhost = $build
|
|
||||||
if $build == "" {
|
|
||||||
$buildhost = $host
|
|
||||||
}
|
|
||||||
if $buildhost == "linode" {
|
|
||||||
$buildhost = "isaiah"
|
|
||||||
}
|
|
||||||
nixos-rebuild switch --use-remote-sudo --use-substitutes --target-host $host --build-host $buildhost
|
|
||||||
}
|
|
||||||
|
|
||||||
def ff [ $file: string ] {
|
|
||||||
ls **/* | where name =~ $file
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
settings = {
|
settings = {
|
||||||
buffer_editor = lib.getExe config.programs.nixvim.package;
|
buffer_editor = lib.getExe config.programs.nixvim.package;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
def par-map [ items: list, c: closure ] {
|
||||||
|
let results = $items | par-each -k $c
|
||||||
|
$items | enumerate | reduce -f {} {|e, a| $a | upsert $e.item { $results | get $e.index }}
|
||||||
|
}
|
||||||
|
|
||||||
|
def --env unlock [] {
|
||||||
|
if "BW_SESSION" not-in $env {
|
||||||
|
$env.BW_SESSION = ^bw unlock --raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def rebuild [] {
|
||||||
|
if (uname | get operating-system) == "Darwin" {
|
||||||
|
sudo darwin-rebuild switch
|
||||||
|
} else {
|
||||||
|
let hostname = uname | get nodename
|
||||||
|
let build = ^nom build $"/etc/nixos#nixosConfigurations.($hostname).config.system.build.toplevel" | complete
|
||||||
|
if build.exit_code == 0 {
|
||||||
|
nvd diff /run/current-system result
|
||||||
|
sudo nixos-rebuild switch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def deploy [ $host: string, $build: string = "" ] {
|
||||||
|
mut buildhost = $build
|
||||||
|
if $build == "" {
|
||||||
|
$buildhost = $host
|
||||||
|
}
|
||||||
|
if $buildhost == "linode" {
|
||||||
|
$buildhost = "isaiah"
|
||||||
|
}
|
||||||
|
nixos-rebuild switch --use-remote-sudo --use-substitutes --target-host $host --build-host $buildhost
|
||||||
|
}
|
||||||
|
|
||||||
|
def ff [ $file: string ] {
|
||||||
|
ls **/* | where name =~ $file
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user