Skip to content

Instantly share code, notes, and snippets.

const fs = require("fs")
try {
fs.createReadStream("/tmp")
} catch (e) {
console.error("hello")
console.error(e)
}
@lheckemann
lheckemann / 0-readme.md
Last active March 11, 2024 13:11
Expression for a buildEnv-based declarative user environment.

Expression for a buildEnv-based declarative user environment

This is one way of managing your user profile declaratively.

Alternatives include:

  • an attrset-based nix-env-based environment, installed using nix-env -ir rather than nix-env --set. LnL has an overlay which shows a way of doing this.
  • home-manager, which provides NixOS-like config for your $HOME

Note that this is incompatible with regular imperative use of nix-env, e.g. nix-env -iA nixpkgs.hello. It has the advantage of allowing the installation of multiple outputs of the same package much better than nix-env's builtin profile builder does.

{
systemd.services.caps-escape-console = {
wantedBy = ["multi-user.target"];
after = ["systemd-vconsole-setup.service"];
path = [ pkgs.kbd ];
script = ''
echo 'keycode 58 = Escape' | loadkeys
'';
};
}
/*
A set of applications which is lightweight in terms of build closure but makes
using a system a lot more pleasant.
*/
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
((vimUtils.makeCustomizable vim).customize {
name = "vim";
vimrcConfig = {
#!/usr/bin/env nix-shell
#! nix-shell -i bash -E "with import <nixpkgs> {}; mkShell {buildInputs = [pkgconfig]; shellHook = ''echo hello'';}"
echo world
@lheckemann
lheckemann / 0-install
Last active January 13, 2019 13:45
nice cursors for urxvt
nix-build -E 'with import <nixpkgs> {}; rxvt_unicode.overrideAttrs (o: {patches = [(builtins.fetchurl https://gist.githubusercontent.com/lheckemann/a613f7eaf19b5fdd8b490ff7019de134/raw/bae5dccf7c5fdf20bec44ad337f0f20ebcd91495/urxvt-nice-cursors.patch)] ++ o.patches or []; buildInputs = [xorg.libXcursor] ++ o.buildInputs or []; nativeBuildInputs = [autoreconfHook] ++ o.nativeBuildInputs or [];})'
pool: thirtythree
state: ONLINE
scan: scrub repaired 0B in 0h1m with 0 errors on Fri Mar 15 19:43:58 2019
config:
NAME STATE READ WRITE CKSUM
thirtythree ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
# 6min kernel, 7m30 zfs, on community box
{ pkgs ? import <nixpkgs> {}}: with pkgs;
linuxPackagesFor ((buildLinux rec {
src = fetchFromGitHub {
owner = "friendlyarm";
repo = "kernel-rockchip";
rev = "decbad503ca983f939baca6c19a79117b11f5bd6";
sha256 = "1mwykah9yr68gscrc8lqi3jay4553yq9cs86m5b21wizm5ikhpfn";
};
version = "4.4.154";
{ pkgs ? import <nixpkgs> {} }: with pkgs;
let linuxPackages = callPackage /etc/nixos/thirtythree/kernel.nix {}; in
rec {
linux = linuxPackages.kernel;
initrd = (makeInitrd {
contents = [
{ object = init; symlink = "/sbin/init"; }
{ object = init; symlink = "/init"; }
{ object = "${modulesClosure}/lib"; symlink = "/lib"; }
];
[root@thirtythree:~]# zfs inherit mountpoint thirtythree/nixos/root
umount: /: target is busy.
cannot unmount '/': umount failed
[root@thirtythree:~]# zfs list thirtythree/nixos/root
NAME USED AVAIL REFER MOUNTPOINT
thirtythree/nixos/root 3.14G 1.99T 3.14G /