README.md Simplify Setup of Nix and flakes and docker image creation instructions

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
Thierry Laurion 2024-05-10 15:44:34 -04:00
parent c52fd42802
commit ecbfdbc57b
No known key found for this signature in database
GPG Key ID: 9A53E1BB3FF00461

View File

@ -39,36 +39,21 @@ Under QubesOS?
Build docker from nix develop layer locally Build docker from nix develop layer locally
==== ====
If you do not use Nix on a daily basis: #### Set up Nix and flakes
```
# DANGER: remove /nix store and recreates a fresh one. Skip if you use Nix already:
sudo rm -rf /nix/* || echo "cannot delete /nix" && sh <(curl -L https://nixos.org/nix/install) --no-daemon
# Configure nix for local builds for nix-commands and flakes usage under nix which are considered experimental features
mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >~/.config/nix/nix.conf
# Source nix prior of anything else:
. /home/user/.nix-profile/etc/profile.d/nix.sh
```
If you use Nix on a daily basis: * If you don't already have Nix, install it:
``` * `[ -d /nix ] || sh <(curl -L https://nixos.org/nix/install) --no-daemon`
# Make sure your nix setup supports both nix-command and flakes experimental features: * `. /home/user/.nix-profile/etc/profile.d/nix.sh`
mkdir -p ~/.config/nix * Enable flake support in nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf * `mkdir -p ~/.config/nix`
# Review ~/.config/nix/nix.conf for inconsistencies in your favorite editor (vim, vi, gedit etc) * `echo 'experimental-features = nix-command flakes' >>~/.config/nix/nix.conf`
# Build nix developer local env with flakes locks to specified versions and exits just running "true" command:
nix --print-build-logs --verbose develop --ignore-environment --command true
# Build docker image with current develop created environment (this will take a while and create "linuxboot/heads:dev-env" local docker image:
nix build .#dockerImage && docker load < result
```
Common steps to follow to build local doscker image from nix develop environment: #### Build image
```
# Build nix developer local env with flakes locks to specified versions and exits just running "true" command: * Build nix developer local environment with flakes locked to specified versions
nix --print-build-logs --verbose develop --ignore-environment --command true * `nix --print-build-logs --verbose develop --ignore-environment --command true`
# Build docker image with current develop created environment (this will take a while and create "linuxboot/heads:dev-env" local docker image: * Build docker image with current develop created environment (this will take a while and create "linuxboot/heads:dev-env" local docker image:
nix build .#dockerImage && docker load < result * `nix build .#dockerImage && docker load < result`
```
Done! Done!