Revert "shell.nix: remove rebuild command"

This reverts commit b954963e36.
This commit is contained in:
Timothy DeHerrera 2020-08-02 15:24:00 -06:00
parent c09d867f11
commit 1870fa29bd
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122
2 changed files with 23 additions and 7 deletions

View File

@ -57,14 +57,20 @@ ln -s $PWD /etc/nixos
# adding a new file to staging is enough: # adding a new file to staging is enough:
git add ./hosts/${new_host}.nix git add ./hosts/${new_host}.nix
# Test your new deployment: # A generic `rebuild` wrapper for `nix build` is provided
sudo nixos-rebuild $new_host test # bypassing the need for `nixos-rebuild`.
# Usage: rebuild [host] {switch|boot|test|dry-activate}
# where `host` is any file living in the `./hosts` directory
# Test your new deployment; this will be run as root:
rebuild $new_host test
# You may wish to start by creating a user: # You may wish to start by creating a user:
mkdir users/new-user && $EDITOR users/new-user/default.nix mkdir users/new-user && $EDITOR users/new-user/default.nix
# Once your satisfied, permanently deploy with: # Once your satisfied, permanently deploy with:
sudo nixos-rebuild $new_host switch rebuild $new_host switch
``` ```
Please read the [doc](DOC.md) in order to understand the impetus Please read the [doc](DOC.md) in order to understand the impetus
@ -74,7 +80,7 @@ behind the directory structure.
```sh ```sh
# Make an iso image based on `./hosts/niximg.nix`: # Make an iso image based on `./hosts/niximg.nix`:
build-iso rebuild iso
# Install any package the flake exports: # Install any package the flake exports:
nix profile install ".#packages.x86_64-linux.myPackage" nix profile install ".#packages.x86_64-linux.myPackage"

View File

@ -1,14 +1,24 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }:
let let
configs = "${toString ./.}#nixosConfigurations"; configs = "${toString ./.}#nixosConfigurations";
hostname = pkgs.lib.fileContents /etc/hostname;
build = "config.system.build";
buildIso = pkgs.writeShellScriptBin "build-iso" '' rebuild = pkgs.writeShellScriptBin "rebuild" ''
nix build ${configs}.niximg.config.system.build.isoImage $@ 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
sudo -E nix shell -vv ${configs}.${hostname}.${build}.toplevel -c switch-to-configuration $1
else
sudo -E nix shell -vv ${configs}.$1.${build}.toplevel -c switch-to-configuration $2
fi
''; '';
in in
pkgs.mkShell { pkgs.mkShell {
name = "nixflk"; name = "nixflk";
nativeBuildInputs = with pkgs; [ git git-crypt nixFlakes buildIso ]; nativeBuildInputs = with pkgs; [ git git-crypt nixFlakes rebuild ];
shellHook = '' shellHook = ''
mkdir -p secrets mkdir -p secrets