Skip to content

Instantly share code, notes, and snippets.

@LisannaAtHome
LisannaAtHome / configuration.nix
Last active December 4, 2017 05:56
Using a custom channel in a custom module with NixOS
{ config, pkgs, ... }:
let
myCustomChannel = import <myCustomChannel>
{ inherit pkgs; };
in {
imports = [ (import <myCustomChannel/myCustomModule.nix> { inherit myCustomChannel; }) ];
}
{
fixup = options: name: file: stdenvNoCC.mkDerivation
( options //
{ inherit name;
installPhase =
''cp -r ${file} $out
'';
}
);
wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }:
@LisannaAtHome
LisannaAtHome / installNix.nix
Last active December 10, 2017 05:27
Hack which installs Nix (single-user) to the root account of a non-NixOS fedora-like Linux distro disk image. Should work with other users, just swap them out. installPkgs.nix takes a disk image with Nix already on it and adds packages to its Nix store and a user account's enviornment.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
@LisannaAtHome
LisannaAtHome / nix-set-env.sh
Created January 13, 2018 00:23
Allows you to directly switch into a Nix environment built with buildEnv
#!/usr/bin/env bash
nix-env -ir -E "args: (import <nixpkgs> {}).lib.toDerivation $1"
@LisannaAtHome
LisannaAtHome / git-extract.sh
Created January 26, 2018 06:27
Extracts all the changes from your HEAD commit and unstages them, leaving the commit message in-place (albeit with a different sha, of course), so it's easier to go back and fix the commit with visual diff -enabled editors (since the changes will show up as unstaged, and will usually be colorized).
#!/usr/bin/env bash
git log --format=%B -n 1 HEAD > ._GIT_EXTRACT_MSG && git reset --soft HEAD^ && git reset HEAD && git commit --allow-empty -F ._GIT_EXTRACT_MSG && rm ._GIT_EXTRACT_MSG
@LisannaAtHome
LisannaAtHome / help.md
Last active April 30, 2022 12:43
Lisanna's eclectic nix troubleshooting guide for suicidal power users

Lisanna's eclectic nix troubleshooting guide for suicidal power users

tar fails with exit code 1

unpacking 'https://example.com/nixexprs.tar.xz'...
tar: Error opening archive: Failed to open '/nix/store/411sszfqfya5ad2wllmqcr15z5d30575-nixexprs.tar.xz'
error: program 'tar' failed with exit code 1

Discussion:

@LisannaAtHome
LisannaAtHome / nix-surgeon.sh
Last active November 14, 2018 10:25
nix-surgeon: tool for repairing corrupted nix store paths
#! /usr/bin/env bash
NIX_STORE=${NIX_STORE:-"/nix/store"};
store_path=$1;
# check if path is actually broken
if nix-store --verify-path $store_path; then exit 0; fi;
# abuse --check flag to get a fresh, non-substituted rebuild of the path
# TODO: GC?
@LisannaAtHome
LisannaAtHome / README.md
Created July 9, 2019 06:50
Better git commit viewing and editing

I created these small git commands to help make exploring commits and editing them easier.

The first set of commands, git uc (Undo Commit) and git rc (Redo Commit), will undo a commit while saving the commit message and keeping the changes staged, so you can make changes to the commit and re-perform the commit while having the original commit message restored. Example:

$ git uc
...make edits to staged changes...
$ git rc
...update commit message, original one is loaded into editor...