In which tidbits regarding nix can be found...
Inherit
# introduces the 'hi' attribute to the following scope
# only valid inside a let block
nix-repl> let inherit ({greeting = "helloworld";}) greeting; in greeting
"helloworld"
System nixpkgs
import <nixpkgs> {};
Git nixpkgs
let
inherit (import <nixpkgs> {}) fetchFromGitHub:
nixpkgs = fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
rev = "00abc...12300";
sha256 = "345oeu...nth876";
};
in ...
Build a package from a channel
nix build -f channel:$CHANNEL hello
Install a package from a channel
nix-env -f https://github.com/NixOS/nixpkgs-channels/archive/${CHANNEL}.tar.gz -iA hello
Remove old generations
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations old
nix-collect-garbage -d
nix-env -p /nix/var/nix/profiles/system --list-generations
## Remove entries from /boot/loader/entries:
find /boot/loader/entries ! -name nixos-generation-${CURRENT_GENERATION_NUMBER}.conf -type f -exec sudo rm {} +
Deploy to GCP
- create GCP account
- create project
foo
- create service account
bar
- download a JSON key for
bar
locally and note its path - export these variables:
export GCE_PROJECT=foo
export GCE_SERVICE_ACCOUNT=bar@iam.gserviceaccount.com
export ACCESS_KEY_PATH=/path/to/key.json
- write a nix expression containing your desired network
let baz = qux; in { network; }
nixops create -d foonet ./file.nix ./file2.nix
nixops deploy -d foonet
- edit expressions as desired and then
nixops modify -d foonet ./file.nix ./file2.nix
nixops deploy -d foonet
- if anything gets into a wonky state
nixops deploy -d foonet --check
- if all else fails, turn it off and on again
nixops destroy -d foonet --confirm
nixops deploy -d foonet