Clean up strings
[?]
Mar 22, 2023, 7:05 PM
VUARRVTIHYO4S574PJNJYJ4CFNAV2TQZ7S2C5TCRBHSVI255FR7ACDependencies
- [2]
J2SBQJQUTweaks - [3]
SNO57YN4Move libdemo and fix linting - [4]
ZW6MBGKCFix CI - [5]
QSIJOFRUTweak 03 - [6]
42DGMBYMFix CI - [7]
IWF26CBIMove baby - [8]
ZYNDBBN3Update some texts - [9]
NYO63G7WUse demonote - [10]
UWWBKZ4RImprove README - [11]
VMUKZQZRWork on 02-nix-build - [12]
WK2OO4YYTweak 04 - [13]
VXZ5QMIEFix CI - [14]
5LP7FPFXFix CI - [15]
EGQ4SEV5Add demo for 04 - [16]
TEQJC3HXAdd 03-nix-container - [17]
M5U5PAX7Add wrapper script, improve libdemo - [18]
ZV5WPO25Extend 02 - [19]
52F4Q6CJUpdate README - [20]
X3HISPCSAdd 05-static-container - [21]
JGZ7GBCLAdd linting - [22]
4ZATYF22Add license - [23]
QICPGJ2DMake simple.c dump more concise - [24]
VX6OFBL3Tweak 05 - [25]
7QIEZSZIAdd tiv - [26]
H2XT7GYITweak 02 - [27]
ZFMPQAFVFix and extend cross compilation with static builds - [28]
7AUC4NKIInitial commit - [29]
OB2MOPJ6Update 02
Change contents
- replacement in README.md at line 65
Because of how the command evaluation is structured, care must be taken with characters that bash might interpret, in particular `'`, `;`, and `|`, which may need escaping to `\'`, `\;`, and `\|` respectively.Because of how the command evaluation is structured, care must be taken with characters that bash might interpret, escaping them where necessary. - replacement in 05-static-container/demo.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 05-static-container/demo.sh at line 9
h Putting wttr-delft into a container as a small static binary, We now combine our knowledge of making OCI containers with our knowledge of making static binariesh "Putting wttr-delft into a container as a small static binary", "We now combine our knowledge of making OCI containers with our knowledge of making static binaries" - replacement in 05-static-container/demo.sh at line 13
h Build the containerh "Build the container" - replacement in 05-static-container/demo.sh at line 16
n It\'s a lot smaller than before!n "It's a lot smaller than before!" - edit in 05-static-container/demo.sh at line 21
h All done with this part!p - replacement in 05-static-container/demo-inside-nix-develop.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 05-static-container/demo-inside-nix-develop.sh at line 9
h Now we are inside a development shell that has rootless podman again., We repeat what we did earlier:h "Now we are inside a development shell that has rootless podman again.", "We repeat what we did earlier:" - replacement in 05-static-container/demo-inside-nix-develop.sh at line 12
h We start by loading the container we just made into the registry:h "We start by loading the container we just made into the registry:" - replacement in 05-static-container/demo-inside-nix-develop.sh at line 15
h We can see it\'s there, and it\'s tiny!h "We can see it's there, and it's tiny!" - replacement in 05-static-container/demo-inside-nix-develop.sh at line 18
h And now we can run it:h "And now we can run it:" - replacement in 05-static-container/demo-inside-nix-develop.sh at line 21
h We have running containers:h "We have running containers:" - replacement in 05-static-container/demo-inside-nix-develop.sh at line 24
h Let\'s kill them and remove them:h "Let's kill them and remove them to clean up after ourselves..." - replacement in 04-cmake-and-cross/demo.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 04-cmake-and-cross/demo.sh at line 11
h Adding CMakeh "Adding CMake" - replacement in 04-cmake-and-cross/demo.sh at line 13
n The more we offload to \'classic\' tools, the easier it is to also build without Nix., This makes it an easier sell to use in most cases\; other people are not forced to use it., Packaging in this way and making use of the sandboxed Nix build process, can help find dependencies that were not correctly declared etc.n "The more we offload to 'classic' tools, the easier it is to also build without Nix.", "This makes it an easier sell to use in most cases; other people are not forced to use it,", "but can use the shared build system in their own environment if so desired.", "Packaging in this way and making use of the sandboxed Nix build process", "can help find dependencies that were not correctly declared etc." - replacement in 04-cmake-and-cross/demo.sh at line 20
n If we add a proper build system like CMake, the Nix part of building a package gets even easier.n "If we add a proper build system like CMake, the Nix part of building a package gets even easier:" - replacement in 04-cmake-and-cross/demo.sh at line 26
h Cross-compilation, The previous build was for x86_64-linux by default because that is our current system:h "Cross-compilation", "The previous build was for x86_64-linux by default because that is our current system:" - replacement in 04-cmake-and-cross/demo.sh at line 30
h We can very easily set up cross-compilation., We use the \'flake-utils\' library to abstract away some of the complications in the flake:h "We can very easily set up cross-compilation:", "We use the 'flake-utils' library to abstract away some of the complications in the flake:", "This also demonstrates how easy it is to combine flakes." - replacement in 04-cmake-and-cross/demo.sh at line 35
, Now we can call a different output:, "Now we can call a different output:" - replacement in 04-cmake-and-cross/demo.sh at line 37
, And this is indeed a RISC-V binary:, "And this is indeed a RISC-V binary:" - replacement in 04-cmake-and-cross/demo.sh at line 40
h Static executables, We can also cross compile a static build:h "Static executables", "We can also cross compile a static build:" - replacement in 04-cmake-and-cross/demo.sh at line 43
, And this is indeed a static binary:, "And this is indeed a static binary:" - replacement in 04-cmake-and-cross/demo.sh at line 47
h Everything together, Static cross compiled for aarch64-linux - you can copy this executable and run it on a Raspberry Pi!h "Everything together", "Static cross compiled binary for aarch64-linux - you can copy this executable and run it on a Raspberry Pi!" - replacement in 04-cmake-and-cross/demo.sh at line 53
h Emulation, If we take a look at what the flake provides we see multiple architectures as well:h "Emulation", "If we take a look at what the flake provides we see multiple architectures as well:" - replacement in 04-cmake-and-cross/demo.sh at line 57
n This will not work if the emulation is not available:, But, if you use NixOS it\'s also very simple to set up binfmt to emulate e.g. aarch64-linux!n "This will not work if the emulation is not available:", "But, if you use NixOS it's also very simple to set up binfmt to emulate e.g. aarch64-linux!" - replacement in 04-cmake-and-cross/demo.sh at line 63
, And we can actually run it as well!, "And we can actually run it as well" - replacement in 03-nix-container/demo.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 03-nix-container/demo.sh at line 9
h Putting wttr-delft into a container, Expanding on the previous nix flake makes building a OCI compliant \(Docker\) image easy:h "Putting wttr-delft into a container", "Expanding on the previous nix flake makes building a OCI compliant (Docker) image easy:" - replacement in 03-nix-container/demo.sh at line 13
h We now choose the \'container\' package we defined:h "We now choose the 'container' package we defined:" - replacement in 03-nix-container/demo.sh at line 15
, "Let's rebuild so we can see what happened...", "This is a 'layered' image, so we might be able to re-use layers at the Docker level." - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 9
h Now we are inside a development shell that has rootless podman., We can manipulate containers just like docker could.h "Now we are inside a development shell that has rootless podman.", "We can manipulate containers just like docker could." - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 12
n We have added the \'dockerCompat\' package so we can use the \'docker\' command instead of \'podman\'.n "We have added the 'dockerCompat' package so we can use the 'docker' command instead of 'podman'.", "In this demo we use it interchangably just to show we can." - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 15
h So we start by loading the container we just made into the registry:h "So we start by loading the container we just made into the registry:" - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 18
h We can see it\'s there:h "We can see it's there:" - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 21
h And now we can run it:h "And now we can run it:" - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 24
h The image is somewhat minimal, e.g. there is no interactive shell:h "The image is somewhat minimal, e.g. there is no interactive shell:" - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 27
h We have running containers:h "We have running containers:" - replacement in 03-nix-container/demo-inside-nix-develop.sh at line 30
h Let\'s kill them and remove them:h "Let's kill them and remove them to clean up after ourselves..." - replacement in 02-nix-build/demo.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 02-nix-build/demo.sh at line 9
h Making our own wttr-delft package, For some reason, we want to have a simple C package that explicitly gets the weather in Delft., We\'re going to use \'libcurl\' for this, and build the executable using nix.h "Making our own wttr-delft package", "For some reason, we want to have a simple C package that explicitly gets the weather in Delft.", "We're going to use 'libcurl' for this, and build the executable using nix." - replacement in 02-nix-build/demo.sh at line 13
h The source code is taken from https://curl.se/libcurl/c/simple.htmlh "The source code is taken from https://curl.se/libcurl/c/simple.html" - replacement in 02-nix-build/demo.sh at line 16
h Using a Nix flake, The modern \(experimental, but recommended\) way to use Nix is to use \'flakes\':h "Using a Nix flake", "The modern (experimental, but recommended) way to use Nix is to use 'flakes':" - replacement in 02-nix-build/demo.sh at line 19
, Flakes are the unit for packaging Nix code in a reproducible and discoverable way., They can have dependencies on other flakes, making it possible to have multi-repository Nix projects., A flake is a filesystem tree \(typically fetched from a Git repository or a tarball\), that contains a file named flake.nix in the root directory., flake.nix specifies some metadata about the flake such as dependencies \(called inputs\),, as well as its outputs \(the Nix values such as packages or NixOS modules provided by the flake\)., "Flakes are the unit for packaging Nix code in a reproducible and discoverable way.", "They can have dependencies on other flakes, making it possible to have multi-repository Nix projects.", "A flake is a filesystem tree (typically fetched from a Git repository or a tarball)", "that contains a file named flake.nix in the root directory.", "flake.nix specifies some metadata about the flake such as dependencies (called inputs),", "as well as its outputs (the Nix values such as packages or NixOS modules provided by the flake)." - replacement in 02-nix-build/demo.sh at line 27
h So, what does a flake look like?h "So, what does a flake look like?" - replacement in 02-nix-build/demo.sh at line 30
h Any inputs are pinned with a lock fileh "Any inputs are pinned with a lock file" - replacement in 02-nix-build/demo.sh at line 33
h So, without further ado, let\'s build our package:h "So, without further ado, let's build our package:" - replacement in 02-nix-build/demo.sh at line 36
h Maybe there was no output\; this means that package was already built and put into the Nix storeh "Maybe there was no output; this means that package was already built and put into the Nix store", "Let's build it again so we can see what happens under the hood" - replacement in 02-nix-build/demo.sh at line 40
h By default, we get a ./result symlink in the current working directoryx find -L "./result"h "By default, we get a ./result symlink in the current working directory that points to the result of our build:"x readlink -f ./resultx find -L "$(readlink -f ./result)" - replacement in 02-nix-build/demo.sh at line 44
h And we can run our executableh "And we can run our executable" - replacement in 02-nix-build/demo.sh at line 47
h We can also just run the executable directly with \'nix run\'h "We can also just run the executable directly with 'nix run'" - replacement in 02-nix-build/demo.sh at line 51
h If we want to do development, we also get that \'for free\' with \'nix develop\':n We do not have gcc available at the moment!h "If we want to do development, we also get that 'for free' with 'nix develop':"n "We do not have gcc available at the moment!" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 9
h Now we are inside a nix-develop shell!h "Now we are inside a nix-develop shell!" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 12
n We started this script to continue the demo\; for normal use \'nix develop\' will drop you into a shell.n "We started this script to continue the demo; for normal use 'nix develop' will drop you into a shell." - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 14
h And we do have gcc:h "And we do have gcc:" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 17
h Not only that, but Nix does all sorts of clever things such as wrapping the compiler:h "Not only that, but Nix does all sorts of clever things such as wrapping the compiler:" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 20
h So that required libraries etc. are available:h "So that required libraries etc. are available:" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 23
h And we can in fact build:h "And we can in fact build:" - replacement in 02-nix-build/demo-inside-nix-develop.sh at line 26
h And run!h "And run!" - replacement in 01-nix-run/demo.sh at line 5
dir="$(dirname "${BASH_SOURCE[0]}")"dir="$(realpath --relative-to="${PWD}" "$(dirname "${BASH_SOURCE[0]}")")" - replacement in 01-nix-run/demo.sh at line 9
h Getting the weather, With Docker we might use \'docker run curlimages/curl wttr.in/Delft\'\;, with Nix we can useh "Getting the weather", "With Docker we might use 'docker run curlimages/curl wttr.in/Delft';", "with Nix we can use the following command:" - replacement in 01-nix-run/demo.sh at line 14
n \'nixpkgs\' is a shorthand way to refer to the main Nix package repository.n "'nixpkgs' is a shorthand way to refer to the main Nix package repository." - replacement in 01-nix-run/demo.sh at line 16
h But we may already have had curl on our path?h "But we may already have had curl on our path?" - replacement in 01-nix-run/demo.sh at line 19
h So to prove \'nix run\' works:h "So to prove 'nix run' actually works, choose a package we don't already have:" - replacement in 01-nix-run/demo.sh at line 23
n In the curl example we were playing fast and loose: the nix run command would just take the latest version.n But for cowsay, we pinned it to a particular revision of nixpkgs.[9.323]n "In the curl example we were playing fast and loose: the nix run command would just take the latest version."n "But for cowsay, we pinned it to a particular revision of nixpkgs."