Skip to content

Add nixos-generators image helper #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ just switch
just clean
```

To generate a bootable image for a host with `nixos-generators`:

```
just generate-image HOST install-iso
```

For the recipes to work properly, create a `.env` and fill it with the needed environment variables:

```
Expand Down Expand Up @@ -149,6 +155,5 @@ git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs
Some tools and utilities to test

- sops-nix
- nixos-generators
- git-hooks
- nh
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ first-install-disko host target:
sudo nix run 'github:nix-community/disko/latest#disko-install' -- --flake .#{{host}} --disk main {{target}} --show-trace

all: update switch clean optimize

generate-image host format="install-iso":
@echo "Generating $format image for host {{host}}"
./scripts/generate-image.sh {{host}} {{format}}
15 changes: 15 additions & 0 deletions scripts/generate-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Generate a NixOS image using nixos-generators
# Usage: ./scripts/generate-image.sh <host> [format]

set -euo pipefail

if [ "$#" -lt 1 ]; then
echo "Usage: $0 <host> [format]" >&2
exit 1
fi

HOST="$1"
FORMAT="${2:-install-iso}"

exec nix run github:nix-community/nixos-generators -- --flake ".#$HOST" -f "$FORMAT"