Skip to content

Instantly share code, notes, and snippets.

View lucperkins's full-sized avatar
🎯
Focusing

Luc Perkins lucperkins

🎯
Focusing
View GitHub Profile
View nuenv-flake.nix
{
inputs = {
nixpkgs.url = "nixpkgs";
nuenv.url = "github:DeterminateSystems/nuenv";
};
outputs = { self, nixpkgs, nuenv }: let
overlays = [ nuenv.overlays.default ];
systems = [
"x86_64-linux"
View nix-build-nuenv.bash
nix build --print-build-logs "github:DeterminateSystems/nuenv"
# See the result
cat result/share/hello.txt
View path.bash
export PATH=
for i in $packages; do
if [ "$i" = / ]; then i=; fi
PATH=$PATH${PATH:+:}$i/bin
done
View nushell-path.nu
# Parse the __nu_packages environment variable string, where each
# package path is separate by a space, and convert to a list
let packages = ($env.__nu_packages | split row (char space))
# Convert the list to a colon-separated string
let $packagesPath = (
$packages
| each { |pkg| $"($pkg)/bin" }
| str collect (char esep)
)
View nushell-derivation.nix
{
mkNushellDerivation = {
nushell, # A Nushell package
name, # The name of the derivation
src, # The derivation's sources
system, # The host system
packages ? [], # Same as in stdenv
build ? "", # Same as in stdenv
}:
View say-hello-help.nu
Say hello to <name> and add a ! to the end if <exclaim> is set.
Usage:
> sayHello {flags} <name>
Flags:
-e, --exclaim - Whether to add a ! at the end
-h, --help - Display the help message for this command
Parameters:
View say-hello.nu
# Say hello to <name> and add a ! to the end if <exclaim> is set.
def sayHello [
name: string, # The person to say hello to
--exclaim(-e): bool, # Whether to add a ! at the end
] {
echo $"Hello, ($name)(if $exclaim { "!" })"
}
View nix-copy-s3.sh
nix copy \
--to "s3://my-nix-stuff-bucket?region=ap-southeast-1" \
".#my-package"
View nix-copy-ponysay.sh
nix copy \
--to ssh-ng://root@"${DROPLET_IP}" \
".#packages.x86_64-linux.ponysay"
View nix-copy-build-closure.sh
nix copy \
--derivation \
--to ssh-ng://"${CLOUD_VM_IP}" \
".#packages.x86_64-linux.service-pkg"