From ed94fa013d791bf8c3d06ab05017e7776f266dbf Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Wed, 1 Jan 2020 21:55:19 -0700 Subject: [PATCH] shell.nix: basic command to build nixos `nixos-rebuild` has unstable flake support. By adding a simple rebuild command to the shell, we don't need to reply on it to switch configurations anymore. At least until it stablizes. --- shell.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/shell.nix b/shell.nix index e5c4214e..c677a807 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,24 @@ { pkgs ? import {} }: +let + configs = "${toString ./.}#nixosConfigurations"; + hostname = pkgs.lib.fileContents /etc/hostname; + build = "config.system.build"; + + rebuild = pkgs.writeShellScriptBin "rebuild" '' + if [[ -z $1 ]]; then + echo "Usage: $0 [host] {switch|boot|test|iso}" + elif [[ $1 == "iso" ]]; then + nix build ${configs}.niximg.${build}.isoImage + elif [[ -z $2 ]]; then + nix run -vv ${configs}.${hostname}.${build}.toplevel -c switch-to-configuration $1 + else + nix run -vv ${configs}.$1.${build}.toplevel -c switch-to-configuration $2 + fi + ''; +in pkgs.mkShell { nativeBuildInputs = with pkgs; [ + rebuild nixFlakes ];