summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nix/rebuild-system.nix23
-rw-r--r--rebuild-system13
2 files changed, 22 insertions, 14 deletions
diff --git a/nix/rebuild-system.nix b/nix/rebuild-system.nix
index ea19a6b..9e8f602 100644
--- a/nix/rebuild-system.nix
+++ b/nix/rebuild-system.nix
@@ -1,21 +1,28 @@
1{ stdenv 1{ stdenv
2, fetchgit 2, fetchgit
3, makeWrapper 3, makeWrapper
4, git 4, zsh, git
5}: 5}:
6 6
7stdenv.mkDerivation rec { 7stdenv.mkDerivation rec {
8 inherit git;
9 name = "rebuild-system-${version}"; 8 name = "rebuild-system-${version}";
10 version = "0.1"; 9 version = "0.2";
11 src = ../rebuild-system; 10 src = ../rebuild-system;
11
12 buildInputs = [ makeWrapper ]; 12 buildInputs = [ makeWrapper ];
13 phases = ["installPhase"]; 13
14 phases = [ "buildPhase" "installPhase" ];
15
16 inherit zsh git;
17
18 buildPhase = ''
19 substituteAll $src rebuild-system
20 '';
21
14 installPhase = '' 22 installPhase = ''
15 mkdir -p $out/bin 23 mkdir -p $out/bin
16 cp $src $out/bin/rebuild-system 24
17 chmod +x $out/bin/rebuild-system 25 install -m 755 -t $out/bin \
18 wrapProgram $out/bin/rebuild-system \ 26 rebuild-system
19 --prefix PATH : ${git}/bin
20 ''; 27 '';
21} 28}
diff --git a/rebuild-system b/rebuild-system
index 8f116e3..cd99ae5 100644
--- a/rebuild-system
+++ b/rebuild-system
@@ -1,11 +1,12 @@
1#!/usr/bin/env bash 1#!@zsh@/bin/zsh
2 2
3if [[ "$USER" != "root" ]]; then 3set -o errexit
4
5if [[ $(whoami) != "root" ]]; then
4 exec sudo -- $0 $@ 6 exec sudo -- $0 $@
5fi 7fi
6 8
7path=/etc/nixos 9configPath=$(nix-instantiate --eval --expr '<nixos-config>')
8 10
9git -C $path pull && \ 11@git@/bin/git -C ${configPath:h} pull
10 git -C $path submodule update && \ 12nixos-rebuild $@
11 nixos-rebuild $@