Skip to content

Instantly share code, notes, and snippets.

@edef1c
Last active August 17, 2019 23:22
Show Gist options
  • Save edef1c/405e3df334272bb61fe60d5b03bc4d5f to your computer and use it in GitHub Desktop.
Save edef1c/405e3df334272bb61fe60d5b03bc4d5f to your computer and use it in GitHub Desktop.
NixOS deployment scripts
nixos-rebuild
#!/usr/bin/env bash
set -ue
export NIX_PATH="nixpkgs=$PWD/nixpkgs:nixos-config=$PWD/configuration.nix"
self="$(basename "$0")"
args=()
if [ "$self" = "nixos-rebuild" ]; then
hostname="$(nix-instantiate '<nixpkgs/nixos>' --eval -A config.networking.hostName)"
hostname="${hostname:1:-1}"
args+=(--target-host "root@$hostname")
fi
exec "$self" "${args[@]}" "$@"
#! /usr/bin/env bash
set -ue
git fetch https://github.com/NixOS/nixpkgs-channels nixos-unstable
date_of() { git log --date=short --pretty=format:%cd -1 "$1"; }
subtree=nixpkgs
merge_base=$(git merge-base HEAD FETCH_HEAD) || exec git subtree add --prefix=$subtree FETCH_HEAD -m "$subtree: init at $(date_of FETCH_HEAD)"
exec git merge -Xsubtree=$subtree FETCH_HEAD -m "$subtree: $(date_of $merge_base) -> $(date_of FETCH_HEAD)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment