From 885af08edef3eede81101d4303e3a025dc078449 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 16 Jul 2015 19:44:44 +0200 Subject: cleanup, rebuild-system --- nix/cliparg.nix | 4 ++-- nix/default.nix | 3 ++- nix/rebuild-system.nix | 28 ++++++++++++++++++++++++++++ rebuild-system | 11 +++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 nix/rebuild-system.nix create mode 100644 rebuild-system diff --git a/nix/cliparg.nix b/nix/cliparg.nix index fcb2066..8aa9a71 100644 --- a/nix/cliparg.nix +++ b/nix/cliparg.nix @@ -1,7 +1,7 @@ { stdenv , fetchgit -, makeWrapper -, xclip +, makeWrapper +, xclip }: stdenv.mkDerivation rec { diff --git a/nix/default.nix b/nix/default.nix index 9aadc46..de52fd4 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -3,5 +3,6 @@ let pkgs = import {}; in rec { - cliparg = pkgs.callPackage (import ./cliparg.nix) {}; + cliparg = pkgs.callPackage ./cliparg.nix {}; + rebuild-system = pkgs.callPackage ./system-rebuild.nix {}; } diff --git a/nix/rebuild-system.nix b/nix/rebuild-system.nix new file mode 100644 index 0000000..b787392 --- /dev/null +++ b/nix/rebuild-system.nix @@ -0,0 +1,28 @@ +{ stdenv +, fetchgit +, makeWrapper +, sudo +, git +}: + +stdenv.mkDerivation rec { + inherit sudo git; + name = "rebuild-system-${version}"; + version = "0.1"; + src = fetchgit { + inherit name; + url = git://git.yggdrasil.li/utils; + rev = ""; + sha256 = ""; + }; + buildInputs = [ makeWrapper ]; + buildPhase = "true"; + installPhase = '' + mkdir -p $out/bin + cp $src/rebuild-system $out/bin/ + chmod +x $out/bin/rebuild-system + wrapProgram $out/bin/rebuild-system \ + --prefix PATH : ${sudo}/bin \ + --prefix PATH : ${git}/bin + ''; +} diff --git a/rebuild-system b/rebuild-system new file mode 100644 index 0000000..8f116e3 --- /dev/null +++ b/rebuild-system @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +if [[ "$USER" != "root" ]]; then + exec sudo -- $0 $@ +fi + +path=/etc/nixos + +git -C $path pull && \ + git -C $path submodule update && \ + nixos-rebuild $@ -- cgit v1.2.3