From ebe31a755f201ac8c9c747bf3fe33bccf3a758b8 Mon Sep 17 00:00:00 2001 From: Thierry Laurion Date: Fri, 10 May 2024 15:44:34 -0400 Subject: [PATCH] README.md Simplify Setup of Nix and flakes and docker image creation instructions Signed-off-by: Thierry Laurion --- README.md | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 98fea8020..e8489674f 100644 --- a/README.md +++ b/README.md @@ -36,39 +36,24 @@ Under QubesOS? * Install docker under QubesOS (imperfect old article of mine. Better somewhere?) * https://gist.github.com/tlaurion/9113983bbdead492735c8438cd14d6cd -Build docker from nix develop layer locally +Build docker from nix develop layer locally ==== -If you do not use Nix on a daily basis: -``` -# 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 -``` +#### Set up Nix and flakes -If you use Nix on a daily basis: -``` -# Make sure your nix setup supports both nix-command and flakes experimental features: -mkdir -p ~/.config/nix -echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf -# Review ~/.config/nix/nix.conf for inconsistencies in your favorite editor (vim, vi, gedit etc) -# 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 -``` +* If you don't already have Nix, install it: + * `[ -d /nix ] || sh <(curl -L https://nixos.org/nix/install) --no-daemon` + * `. /home/user/.nix-profile/etc/profile.d/nix.sh` +* Enable flake support in nix + * `mkdir -p ~/.config/nix` + * `echo 'experimental-features = nix-command flakes' >>~/.config/nix/nix.conf` -Common steps to follow to build local doscker image from nix develop environment: -``` -# 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 -``` +#### Build image + +* Build nix developer local environment with flakes locked to specified versions + * `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` Done!