Skip to content

Instantly share code, notes, and snippets.

View 573's full-sized avatar

Daniel Kahlenberg 573

View GitHub Profile
@thiloho
thiloho / getting-started-with-nix.md
Last active April 25, 2024 11:59
Getting started with the Nix ecosystem

A snowflake through a magnifying glass

Getting started with the Nix ecosystem

What is this article about?

When I first started to learn how to use NixOS, the Nix package manager, and how to work with the Nix language, I was overwhelmed. While it did not take me too long to (sort of) get into it, it was not the most pleasant experience. I would say that there is not really a single source of truth, like Arch Linux users have with the ArchWiki, where you can basically look up everything. Instead, the information is spread across many different sources, which can make it difficult for beginners to find out how to do what they want to do.

The "modern nix CLI", also known as "nix3 cli", is another thing that can cause confusion when you are just starting your nix journey. There are some commands that look almost exactly the same, such as nix shell compared to nix-shell or nix-build compa

import sys
import functools
callstack = []
@functools.cache
def lookup(func):
try:
parts = func.split(":")
with open(parts[0]) as f:
@VictorTaelin
VictorTaelin / implementing_fft.md
Last active April 30, 2024 05:32
Implementing complex numbers and FFT with just datatypes (no floats)

Implementing complex numbers and FFT with just datatypes (no floats)

In this article, I'll explain why implementing numbers with just algebraic datatypes is desirable. I'll then talk about common implementations of FFT (Fast Fourier Transform) and why they hide inherent inefficiencies. I'll then show how to implement integers and complex numbers with just algebraic datatypes, in a way that is extremely simple and elegant. I'll conclude by deriving a pure functional implementation of complex FFT with just datatypes, no floats.

@toraritte
toraritte / nix_pin_version_of_individual_packages.md
Last active March 22, 2024 15:30
(work in progress) State of affairs on how to pin versions of individual Nix packages (or how to refer to a specific package version with Nix)

Yes, there are several ways to do this, but none of them are as direct and simple as git v2.1.2; htop v1.2.3 and come with a lot of caveats.

aside
Specifying versions for programming language packages are possible too, but that topic seems to be even messier. The most promising standardization effort to date is [dream2nix][1].

0. Methods

That is, available at the time of this writing:

0.1 "versioned" attribute paths (if available)

@voidus
voidus / flake.nix
Created April 22, 2023 18:35
Build a cloudinit image in nixos
{
description = "A nixos cloudinit base image without nixos-infect";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
@dkandalov
dkandalov / plugin.kts
Last active October 19, 2022 10:56
Examples of using run configs in IntelliJ API
import com.intellij.coverage.CoverageExecutor
import com.intellij.execution.ExecutorRegistry
import com.intellij.execution.RunManager
import com.intellij.execution.RunnerAndConfigurationSettings
import com.intellij.execution.application.ApplicationConfiguration
import com.intellij.execution.application.ApplicationConfigurationType
import com.intellij.execution.executors.DefaultDebugExecutor
import com.intellij.execution.executors.DefaultRunExecutor
import com.intellij.execution.junit.JUnitConfiguration
import com.intellij.execution.junit.JUnitConfigurationType
@ClassicDarkChocolate
ClassicDarkChocolate / ScoopExtensions.ps1
Last active September 10, 2023 20:51
Commands: Get-ScoopPackageVersions, Invoke-ScoopPackageCommand, Install-ScoopPackage
function Get-ScoopRoot {
$scoopdir = & {
$env:SCOOP, (scoop config 'rootPath'), "$env:USERPROFILE\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
} 6>$null
$scoopdir
}
function Get-ScoopPackageVersions {
param (
[Parameter(Position = 1, Mandatory = $true)]
@InternetUnexplorer
InternetUnexplorer / command-not-found.sh
Last active March 17, 2024 11:53
Improved home-manager nix-locate configuration, with an auto-updated index and a better command-not-found handler
# Adapted from https://github.com/bennofs/nix-index/blob/master/command-not-found.sh
command_not_found_handle () {
if [ -n "${MC_SID-}" ] || ! [ -t 1 ]; then
>&2 echo "$1: command not found"
return 127
fi
echo -n "searching nix-index..."
ATTRS=$(@nix-locate@ --minimal --no-group --type x --type s --top-level --whole-name --at-root "/bin/$1")
@sorki
sorki / libvirt.nix
Created May 11, 2022 13:13
libvirt with statically configured bridge
# Module for configuring libvirt with static NixOS networking
# instead of using libvirt managed bridge.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.virtualisation.libvirtd.networking;
v6Enabled = cfg.ipv6.network != null;
v6PLen = toInt (elemAt (splitString "/" cfg.ipv6.network) 1);
@udf
udf / write_up.md
Last active April 18, 2024 11:44
A Trick To Use mkMerge at The Top Level of a NixOS module

The Setup

I wanted to write a module that generates multiple systemd services and timers to scrub some zfs pools at certain intervals. The default scrub config does not support individual scrub intervals for each pool.

I want the config to look like this:

{
  services.zfs-auto-scrub = {
 tank = "Sat *-*-* 00:00:00";