• Operand
  • de ploy? ed.

gram:build

> ./config/nushell/nix.nu

Lenses
(coming soon!)


source ./day.nu

def nsh --wrapped [ command:string, ...params ] {
  let params = if ($params | is-empty) { [ $command ] } else { $params }
  print (([ $"\(($command)\)>" ] ++ $params ) | str join ' ')
  nix-shell -p $command --command $"(($params) | str join ' ')" }

def rebuild [] { hx ~/.build/nixos; sudo nixos-rebuild switch; }

def upgrade [] { sudo nix-channel --update; cd ~/.build/nixos; nix flake update; sudo nixos-rebuild switch; }

def gc [] {
  sudo nix-collect-garbage --delete-older-than 2d |
  tee { save ([ $env.HOME .build $"(clock | str trim).nix-gc.log" ] | path join) }
}

def nd --wrapped [...command: string] {
  if $command == [] { nix develop
  } else { nix develop --command ...($command) }
}

# def help [
#   package: string,
#   --command (-c): string,
#   --less (-l),
#   --record (-r),
# ] {
#   let command = if ($command | is-empty) { $package } else { $command }
#   if $record { mkdir ~/help
#     echo (nsh $package $command --help) | save -f ($"~/help/($command).help" | path expand) }
#   if $less {
#     nsh $package $command --help | less
#   } else {
#     nsh $package $command --help }
# }