Skip to content

Instantly share code, notes, and snippets.

View lucperkins's full-sized avatar
🎯
Focusing

Luc Perkins lucperkins

🎯
Focusing
View GitHub Profile
@lucperkins
lucperkins / flake.nix
Last active September 12, 2024 17:37
keyboard-configurator flake
{
description = "System76 Keyboard Configurator";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
naersk.url = "github:nix-community/naersk";
};
outputs = { self, nixpkgs, flake-utils, naersk }:
{
inputs = {
nixpkgs.url = "nixpkgs";
nuenv.url = "github:DeterminateSystems/nuenv";
};
outputs = { self, nixpkgs, nuenv }: let
overlays = [ nuenv.overlays.default ];
systems = [
"x86_64-linux"
nix build --print-build-logs "github:DeterminateSystems/nuenv"
# See the result
cat result/share/hello.txt
export PATH=
for i in $packages; do
if [ "$i" = / ]; then i=; fi
PATH=$PATH${PATH:+:}$i/bin
done
# 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)
)
{
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
}:
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:
# 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 { "!" })"
}
nix copy \
--to "s3://my-nix-stuff-bucket?region=ap-southeast-1" \
".#my-package"
nix copy \
--to ssh-ng://root@"${DROPLET_IP}" \
".#packages.x86_64-linux.ponysay"