Skip to content

Instantly share code, notes, and snippets.

View fricklerhandwerk's full-sized avatar

Valentin Gagarin fricklerhandwerk

  • Tweag I/O
  • Hamburg, Germany
View GitHub Profile
@fricklerhandwerk
fricklerhandwerk / nix-maintenance-report-scripts.md
Created February 9, 2024 07:03
Scripts to obtain raw data on Nix maintenance activities

Show all merged pull requests

gh pr list --state merged --search "NOT Backport merged:2023-04-01..2024-01-08" --json number,title --jq '.[] |  "- [#\( .number )](https://github.com/NixOS/nix/pull/\( .number )) \( .title )"' --limit 1000 | sort

Show merged pull requests by selected labels (categories will have overlap)

for label in bug tests documentation UX error-messages performance contributor-experience build-problem new-cli installer language process feature; do echo -e "\n## [$label](https://github.com/NixOS/nix/issues?q=is%3Amerged+label%3A$label+merged%3A2023-03-31..2024-01-08+)\n"; gh pr list --state merged --label "$label" --search "NOT Backport merged:2023-04-01..2024-01-08" --json number,title --jq '.[] |  "- [#\( .number )](https://github.com/NixOS/nix/pull/\( .number )) \( .title )"' --limit 500 | sort
@fricklerhandwerk
fricklerhandwerk / README.md
Last active January 30, 2024 21:08
Home Manager without `home-manager`

Here's how to use Home Manager without home-manager. @proofconstruction is my witness.

Getting the right version of Home Manager

First of all we have to make sure that the version of Home Manager matches the Nixpkgs release we want to use for our user environment configuration. Otherwise we will almost certainly get into trouble with mismatching interfaces.

We start out with a function that takes Nixpkgs as pkgs and fetch the appropriate Home Manager release. We get the given Nixpkgs version string from pkgs.lib.version and split it into the . format with lib.versions.majorMinor.

@fricklerhandwerk
fricklerhandwerk / nix-unix.md
Created December 14, 2022 09:18
Nix as data-flow-oriented abstraction of the Unix paradigm
+-----------------------------------------------------+
| data flow programming                               |
|     .-------.      .----------.      .--------.     |
|     | input | ---> | function | ---> | output |     |
|     '-------'      '----------'      '--------'     |
|         ^                                |          |
+---------|--------------------------------|----------+
          |                                V
       +-------------------------------------+
@fricklerhandwerk
fricklerhandwerk / nix+bazel.md
Created September 13, 2022 10:33
Nix + Bazel
flowchart 
  direction LR
  subgraph Nix
    subgraph Bazel
    source
    BUILD.bazel
    WORKSPACE
    end
 bzl[Bazel] & tools & libraries --> Bazel
@fricklerhandwerk
fricklerhandwerk / stdlib.nix
Created August 26, 2022 23:39
missing standard library functions for the Nix language
with builtins;
{
every = n: xs:
# take every `n`-th element from the list `xs`
if n < 2 then xs else
if xs == [] then [] else
if length (tail xs) < n - 1 then [ (head xs) ] else
[ (head xs) ] ++ every (apply-n-times tail xs n) n
;
@fricklerhandwerk
fricklerhandwerk / involved.fish
Created August 5, 2022 12:41
Query your GitHub involvement in the past
#!/usr/bin/env nix-shell
#!nix-shell -i fish -p gh -I nixpkgs=channel:nixos-22.05
argparse --min-args 2 "h/help" "a/arg=+" -- $argv
or begin echo "
specify query and interval, for example:
pr 1 week
issue 3 days
@fricklerhandwerk
fricklerhandwerk / 2022-nix-book.md
Last active November 25, 2023 17:49
Summer of Nix 2022: The Nix Book

Summer of Nix 2022: The Nix Book

tl;dr

Goals

  • Improve the autodidactic Nix onboarding experience to increase community growth
  • Provide a clear learning path from first impression down to source code

Tasks

@fricklerhandwerk
fricklerhandwerk / networking.sh
Created January 7, 2020 02:41
get IP4 network configuration from /proc/net
#!/bin/bash
# get network configuration for from /proc/net
# original: <https://stackoverflow.com/a/14725655/5147619>
# WARNING: works only for first adapter listed and only for IP4
# NOTE: ip functions set variables instead of returning to STDOUT
hex_to_int() {
@fricklerhandwerk
fricklerhandwerk / nixify.sh
Created January 7, 2020 02:38
Install NixOS over Debian 10 on a VPS
#! /usr/bin/bash
# install NixOS over Debian 10, following and simplifying
# <https://nixos.org/nixos/manual/#sec-installing-from-other-distro>
# PREPARATION: set up /etc/nixos/configuration.nix with authorized SSH keys
set -e -o pipefail
network_config() {
# capture networking configuration from current machine.