Last active
August 17, 2019 23:22
-
-
Save edef1c/405e3df334272bb61fe60d5b03bc4d5f to your computer and use it in GitHub Desktop.
NixOS deployment scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nixos-rebuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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[@]}" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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