Skip to content

Instantly share code, notes, and snippets.

View nat-418's full-sized avatar

Nat nat-418

View GitHub Profile

aspe:keyoxide.org:ESQIYIHUFMW4ZI3NLH3TFYM2CM

@nat-418
nat-418 / packaging-scripts-for-nix.md
Last active March 21, 2024 17:09
Packaging scripts for Nix

Packaging scripts for Nix

In a previous article, I described how to [build a Nix package]. In this article, I will discuss how to package scripts: specifically, how to handle their runtime dependencies.

Let's begin with the example of a simple script:

#!/usr/bin/env xonsh
@nat-418
nat-418 / running-your-own-nix-channel.md
Last active March 24, 2024 20:02
Running your own Nix channel

Running your own Nix channel

In my previous article, [How to build with Nix], I explained how to write a Nix package and contribute it to the official Nix package repository. One of the advantages of Nix is how easy it is to develop your own custom Nix package repository, called a channel. A channel can be implemented simply as a tarball containing a default.nix file like this:

let
  pkgs = import <nixpkgs> {};
in
@nat-418
nat-418 / how-to-build-with-nix.md
Last active April 24, 2024 14:57
How to build with Nix

How to build with Nix

[Nix] is a cross-platform package manager and domain-specific language used to define packages. In this article, I will demonstrate how to write and contribute Nix packages to [Nixpkgs], the [world's largest software repository]. I assume that you, dear reader, already know the basics of software development. Nix brings a number of advantages over comparable packaging solutions, most importantly:

  • more reproducible builds
  • a large and welcoming community
@nat-418
nat-418 / from-init.lua-to-default.nix.md
Last active April 16, 2024 23:40
Advanced Neovim configuration with Nix and Home Manager

From init.lua to default.nix

In a previous post I explained how to manage Neovim plugins with Nix and Home Manager. In this post I want to go further and show how to migrate Neovim configuration from ~/.config/nvim to ~/.config/home-manager entirely. The end result will be to split our Neovim setup into multiple modules that colocate plugin sourcing and configuration.

If you haven't read the post linked above, do so now. We will assume the

@nat-418
nat-418 / why-tcl.md
Last active April 1, 2024 03:23
Why Tcl?

Why Tcl?

Introduction

I use [Tcl] as my scripting language of choice, and recently someone asked me why. This article is an attempt to answer that question.

Ousterhout's dichotomy claims that there are two general categories of programming languages:

@nat-418
nat-418 / a-basic-home-manager.md
Last active January 16, 2024 14:55
An example Home Manager configuration

A basic Home Manager configuration

These files show a simplified real-world example of how to use Home Manager to setup Neovim, Xfce, and some command-line user tools.

@nat-418
nat-418 / libvirt.nix
Last active April 16, 2023 14:07
Basic NixOS configuration for desktop libvirt virtualization
# This file should be sourced in your /etc/nixos/configuration.nix
# imports declaration.
{ pkgs, ... }:
{
environment = {
systemPackages = with pkgs; [
libguestfs-with-appliance
libvirt
libvirt-glib
@nat-418
nat-418 / a-sensible-nixos-xfce-configuration.md
Last active April 11, 2024 16:17
A sensible NixOS Xfce configuration

A sensible NixOS Xfce Configuration

NixOS provides good support for the Xfce desktop environment out-of-the-box, but the defaults are minimal. The files in this Gist provide a more complete experience, including a suite of basic software and plugins as well as an optional home-manager configuration for theming.

The key additions to the default Xfce provided by NixOS are:

  • Complete bluetooth / audio support with panel indicators and apps
  • LightDM with theme
  • Extra Xfce apps for calendaring, disk partitioning, etc.
  • Various quality-of-life improving non-essentials
@nat-418
nat-418 / expecting.md
Created January 8, 2023 15:16 — forked from ksafranski/expecting.md
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect