Skip to content

Instantly share code, notes, and snippets.

View nixosify.sh
#!/bin/sh
if ! command -v nix >/dev/null; then
echo "Installing Nix..."
if command -v curl; then
curl -L https://nixos.org/nix/install > /tmp/install
elif command -v wget; then
wget -O /tmp/install https://nixos.org/nix/install
else
echo "Please install curl or wget"
@Mic92
Mic92 / 0_description.md
Last active May 24, 2023 07:32
Tvix (b67ac82cb15c2667c1742dc64c4e001c6768aea1) vs nix (v2.12.0) evaluation of the hello package
View 0_description.md

Tvix is a new implementation of the Nix language and package manager. In this benchmark we test it's performance when instantiating the hello package from nix. Note that at the time tvix does not have its own store implementation yet and it has to execute nix-store whenever it needs to copy files to the store.

View test-nixos-iso.sh
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p qemu_kvm -p iproute2
set -x -eu -o pipefail
VM_IMAGE=""
CPUS="${CPUS:-$(nproc)}"
MEMORY="${MEMORY:-4096}"
SSH_PORT="${SSH_PORT:-2222}"
IMAGE_SIZE="${IMAGE_SIZE:-10G}"
@Mic92
Mic92 / default.nix
Last active March 11, 2023 17:59
Nix-shell environment to get all dependencies to build openwrt/LEDE (a more up-to-date version can be found here: https://github.com/nix-community/nix-environments#current-available-environments)
View default.nix
# Nix is a powerful package manager for Linux and other Unix systems that makes
# package management reliable and reproducible: https://nixos.org/nix/.
# This file is intended to be used with `nix-shell`
# (https://nixos.org/nix/manual/#sec-nix-shell) to setup a fully-functional
# LEDE build environment by installing all required dependencies.
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "openwrt-dev-env";
buildInputs = [
# This list is more explicit then it have to be: it also includes utils
@Mic92
Mic92 / pushover-warning@.service
Last active February 25, 2023 14:21
Sent pushover warnings when a systemd service failed (useful for backups and systemd timers)
View pushover-warning@.service
[Unit]
Description=pushover warning
[Service]
Type=oneshot
ExecStart=/usr/bin/curl -s \
--form-string "token=<PUSHOVER_APPLICATION_TOKEN>" \
--form-string "user=<PUSHOVER_USER_TOKEN>" \
--form-string "message=service %I at %H failed" \
https://api.pushover.net/1/messages.json
View disk-space
. 242.3 GiB [##########################] /harshanavkis
. 137.1 GiB [############## ] /paul
98.9 GiB [########## ] /julian
. 84.8 GiB [######### ] /dimitrios
. 61.5 GiB [###### ] /maurice
33.0 GiB [### ] /martin
12.1 GiB [# ] /masa
7.8 GiB [ ] /joerg
5.3 MiB [ ] /okelmann
@Mic92
Mic92 / kexec-installer.nix
Last active January 14, 2023 06:42
kexec-based installer for nixos to install nixos from every linux!
View kexec-installer.nix
## USAGE
# $ nix-build kexec-installer.nix
# can be deployed remote like this
# $ rsync -aL -e ssh result/ root@host:
# $ ssh root@host ./kexec-installer
## Customize it like this
# # custom-installer.nix
# import ./kexec-installer.nix {
# extraConfig = {pkgs, ... } {
# user.extraUsers.root.openssh.authorizedKeys.keys = [ "<your-key>" ];
View install-nixos.sh
#!/usr/bin/env bash
set -exuo pipefail
PROGRAM_NAME="$0"
inst() {
local system="" host="" action="install" from="auto" mount=""
local -a nixCopyArgs
while [[ "$#" -gt 0 ]] ; do
case "$1" in
@Mic92
Mic92 / default.nix
Created December 19, 2022 19:45
forgejo
View default.nix
{ lib
, buildGoPackage
, fetchurl
, makeWrapper
, git
, bash
, gzip
, openssh
, pam
, sqliteSupport ? true
View hardware.nix
{
boot.initrd.availableKernelModules = [
"xhci_pci"
"ahci"
"nvme"
];
disko.devices = import ./raid-config.nix {
raidLevel = 1;
};