Notes about nix and MacOS and AMD and ARM
TODO: only neested virtualization on macOS did not word by default. Need to document this.
https://nixcademy.com/posts/nix-on-macos/
Some background about AMD vs ARM
Take a look at:
- God-Tier Developer Roadmap, start=883&end=901
- Is Linux an OS, a kernel or both? (Linux vs GNU/Linux) + https://github.com/apple/darwin-xnu
- How a CPU Works in 100 Seconds // Apple Silicon M1 vs Intel i9
- I use Arch on an M1 MacBook, btw
- Emulation - Computerphile, start=68&end=201
- https://opensource.apple.com/releases/
- 24C3: Inside the Mac OS X Kernel
- GentooBer #048- Darwin, o SO livre da Apple
- Apple won't like this... - Run MacOS on ANY PC
- Run macOS on Linux with 1 COMMAND
- "AArch64" and "ARM64" refer to the same thing.
- https://unix.stackexchange.com/a/755326
- It only supports Linux, not macOS (some people use
brew on Linux)., about dtruss and https://ianthehenry.com/posts/how-to-learn-nix/more-flakes/
-It only supports Linux, not macOS (some people use brew on Linux)., about dtrace
- https://stackoverflow.com/a/54134303 and https://stackoverflow.com/a/67179752 , about
llvm-otool, was it renamed? nix shell nixpkgs#llvm it has llvm-objdump
UTM
It worked, but still missing a lot of documentation!
Why?
I don't think this is an issue that should be fixed on our end, its more of a homebrew install issue, and homebrew specifically states that some packages may break if not installed in their default location
containers/podman#12161 (comment)
I try to install as many packages as possible through Nix, since it’s the only way to synchronize packages across all of NixOS, Arch Linux and MacOS.
From: https://www.fbrs.io/nix-overlays/
The main issue we found with using Docker locally is that docker filesharing is extremely slow, especially on MacOS. The interwebs have plenty of resources to address this problem but these approaches simply mitigate rather than resolve the underlying performance issue.
Docker performance is pretty bad for Rails development but it’s even worse for front-end apps that require a gazillion files to be loaded and written (cough cough webpack). Poor Docker performance usually leads developers to give up on Docker for their frontend - and return to a painfully slow backend development process.
https://tech.precisionnutrition.com/dev-tooling/2020/05/03/speedy-dev-envs-with-nix.html
https://www.slant.co/topics/511/~best-mac-package-managers
https://news.ycombinator.com/item?id=27825420
Setting up nix-darwin home-manager and flakes on M1 Macbook Pro OSX Monterey 12.0.1
Discontinuing support for macOS Monterey
Mitchell is a Co-founder and CTO of HashiCorp, creators of popular tools such as Terraform, Vault, Vagrant, Packer, and more.
List:
TODO: watch it
this Did someone say virtual is slow?, start=76&end=181
+
Walkthrough of Nix Install and Setup on MacOS
+
This Linux PC Runs macOS Faster Than a Real Mac
TODO:
The sandbox
Really watch this:
See https://discourse.nixos.org/t/nixos-virtual-machine-on-apple-m1-arm64/15167 and https://mac.getutm.app/
NixOS/nixpkgs#95903 (comment)
Bugs, many bugs
> # This works on my computer (host: Ubuntu 14.04.1, guest: MINIX 3.2.1). It's
> # not my fault if it doesn't work on yours.
https://gist.github.com/ashaindlin/ebf807cd14b82066058e#file-vm-sh-L19-L20
I tried 10 code editors, start=0&end=19
In my case after copying of the executable the bug that I wanted to debug stopped happening ..(
https://stackoverflow.com/questions/31045575/how-to-trace-system-calls-of-a-program-in-mac-os-x#comment80637364_46799054
how a silent computer bug ended 6 lives
Bugs and more bugs:
Take an look at this:
If you remove the first word from the string "hello world", what should the result be? This is the story of how we discovered that the answer could be your root password!
https://lock.cmpxchg8b.com/zenbleed.html
List:
Domen Kožar - Nix Is Going Mainstream (SoN2022 - public lecture series), start=480&end=516
The NixOS "shebang" and the GNU/Linux kernel:
https://www.youtube.com/embed/QkcjCRE8Vvs?start=673&end=807&version=3
+
https://discussion.fedoraproject.org/t/disabling-selinux-breaks-docker-overlayfs/20232
MWEs + how to never write bug, start=264&end=294
Unfortunately there are really hard/impossible to reproduce bugs:
how to never write bug, start=294&end=319
I too faced similar issues of stuttering. This was because of the input overflowed error which came up during the streaming. If the chunk size of every communication is reduced to 512bytes the communication is coming out well as per my experience.
Ref.: https://stackoverflow.com/a/36214862/9577149
If nothing works:
Specific to javascript, but valid for many other situations:
This kind of bug is scary:
TODO: test is
nix \
--extra-experimental-features 'nix-command flakes ca-derivations' \
realisation \
info \
github:NixOS/nixpkgs/58c85835512b0db938600b6fe13cc3e3dc4b364e#hello
this path will be fetched (0.02 MiB download, 0.11 MiB unpacked):
/nix/store/c4n3i1nfhvcim30s4ij502cw84yl4vdn-hello-2.12.1
error: unexpected end-of-file
nix shell nixpkgs#nix-info --command nix-info --markdown
- system:
"aarch64-darwin"
- host os:
Darwin 22.3.0, macOS 13.2.1
- multi-user?:
yes
- sandbox:
no
- version:
nix-env (Nix) 2.10.2
- channels(root):
"nixpkgs"
- nixpkgs:
/nix/var/nix/profiles/per-user/root/channels/nixpkgs
{"description":"A collection of packages for the Nix package manager","lastModified":1688392541,"locked":{"lastModified":1688392541,"narHash":"sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=","owner":"NixOS","repo":"nixpkgs","rev":"ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","type":"github"},"locks":{"nodes":{"root":{}},"root":"root","version":7},"original":{"id":"nixpkgs","type":"indirect"},"originalUrl":"flake:nixpkgs","path":"/nix/store/gmdhl9qfaic5765lxw2wj6hb2ifjmhjd-source","resolved":{"lastModified":1688392541,"narHash":"sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=","owner":"NixOS","repo":"nixpkgs","rev":"ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","type":"github"},"resolvedUrl":"github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","revision":"ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","url":"github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b"}
nix --extra-experimental-features 'nix-command flakes ca-derivations' realisation info github:NixOS/nixpkgs/nixpkgs-unstable#python3
these 5 paths will be fetched (13.08 MiB download, 68.12 MiB unpacked):
/nix/store/61s4l8b46g3bg9ymcji3bmjv8kzk2sms-readline-8.2p1
/nix/store/bpz8rh8pnlm6zsh64xjk2c7hgc71f99p-gdbm-1.23
/nix/store/f67hia73n1rf333qkwk294g44vkr6rn7-openssl-3.0.10
/nix/store/fd7wwy1bzzpg68pd20gxb02rgwdaa41w-libxcrypt-4.4.36
/nix/store/g5cm6iik6p4k39cj9k7a6sg2p09hl7wf-python3-3.10.12
error: unexpected end-of-file
The rosetta thing
List:
The qemu-user-static thing
What name put here?
macOS to NixOS the Purely Functional Linux Distribution by Daniel Britten
Franz Pletz: NixOS, start=913&end=928, about homebrew vs nix
https://discourse.nixos.org/t/nixos-on-the-new-apple-macbook-m1/15715/2
Remember Mac uses zsh (since when?):
utmapp/UTM#2688 (comment)
MacOS Simple KVM
Part 1:
git clone https://github.com/adisbladis/macOS-Simple-KVM.git \
&& cd macOS-Simple-KVM \
&& git checkout de4114741e5dd0079d04a4d56d275659d0579c31 \
&& (direnv allow || nix-shell)
./jumpstart.sh --mojave \
&& test -f MyDisk.qcow2 || qemu-img create -f qcow2 MyDisk.qcow2 64G \
&& ./basic.sh
For some reason it is need to format the disk in the Disk Utility
?:
test -f MyDisk.qcow2 || qemu-img create -f qcow2 MyDisk.qcow2 64G
HEADLESS=1 MEM=1G CPUS=2 SYSTEM_DISK=MyDisk.qcow2 ./headless.sh
About the installer
TODO: try to test that
NixOS/nix#3616 (comment)
qemu
TODO: it documents part of history: https://stackoverflow.com/a/66887947
TODO: https://www.willhaley.com/blog/debian-arm-qemu/
# nix flake metadata --no-write-lock-file 'github:Mic92/nixos-aarch64-images'
# github:Mic92/nixos-aarch64-images/c29e786f552a5c38e1dcdceb552412ad488e45d3
nix \
build \
--no-write-lock-file \
'github:Mic92/nixos-aarch64-images#aarch64Image'
nix \
build \
--no-write-lock-file \
--override-input nixpkgs github:nixos/nixpkgs/nixpkgs-unstable \
'github:Mic92/nixos-aarch64-images#aarch64Image'
nix profile install nixpkgs#qemu_full
curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-armhf/current/images/cdrom/initrd.gz \
&& curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-armhf/current/images/cdrom/vmlinuz
curl -O -L https://cdimage.debian.org/debian-cd/current/armhf/iso-dvd/debian-11.1.0-armhf-DVD-1.iso
qemu-img create -f qcow2 debian-arm.sda.qcow2 100G
qemu-system-arm \
-m 4G \
-machine type=virt \
-cpu cortex-a7 \
-smp 4 \
-initrd "./initrd.gz" \
-kernel "./vmlinuz" \
-append "console=ttyAMA0" \
-drive file="./debian-11.1.0-armhf-DVD-1.iso",id=cdrom,if=none,media=cdrom \
-device virtio-scsi-device \
-device scsi-cd,drive=cdrom \
-drive file="./debian-arm.sda.qcow2",id=hd,if=none,media=disk \
-device virtio-scsi-device \
-device scsi-hd,drive=hd \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \
-device virtio-net-device,netdev=net0 \
-nographic
https://www.willhaley.com/blog/debian-arm-qemu/
file $(nix --system aarch64-darwin build --no-link --print-out-paths --print-build-logs github:NixOS/nixpkgs/nixpkgs-unstable#qemu)/bin/qemu-system-aarch64
nix --system aarch64-darwin run github:NixOS/nixpkgs/nixpkgs-unstable#qemu -- --version
qemu + NixOS => build-vm
Excelent: Running qemu-system-aarch64 with -accel hvf on aarch64-darwin
Copying files like .img .qcow2
https://serverfault.com/a/670227
https://stackoverflow.com/questions/41733410/remove-qcow2-image-files-holes
Notes about nix and MacOS and AMD and ARM
TODO: only neested virtualization on macOS did not word by default. Need to document this.
https://nixcademy.com/posts/nix-on-macos/
Some background about AMD vs ARM
Take a look at:
brewon Linux)., aboutdtrussand https://ianthehenry.com/posts/how-to-learn-nix/more-flakes/-It only supports Linux, not macOS (some people use
brewon Linux)., aboutdtracellvm-otool, was it renamed?nix shell nixpkgs#llvmit hasllvm-objdumpUTM
It worked, but still missing a lot of documentation!
Why?
https://www.slant.co/topics/511/~best-mac-package-managers
https://news.ycombinator.com/item?id=27825420
Setting up nix-darwin home-manager and flakes on M1 Macbook Pro OSX Monterey 12.0.1
Discontinuing support for macOS Monterey
Mitchell is a Co-founder and CTO of HashiCorp, creators of popular tools such as Terraform, Vault, Vagrant, Packer, and more.
List:
TODO: watch it
this Did someone say virtual is slow?, start=76&end=181
+
Walkthrough of Nix Install and Setup on MacOS
+
This Linux PC Runs macOS Faster Than a Real Mac
TODO:
The sandbox
Really watch this:
See https://discourse.nixos.org/t/nixos-virtual-machine-on-apple-m1-arm64/15167 and https://mac.getutm.app/
NixOS/nixpkgs#95903 (comment)
Bugs, many bugs
I tried 10 code editors, start=0&end=19
how a silent computer bug ended 6 lives
Bugs and more bugs:
https://github.com/NixOS/nix/pull/9860Take an look at this:
List:
Domen Kožar - Nix Is Going Mainstream (SoN2022 - public lecture series), start=480&end=516
The NixOS "shebang" and the GNU/Linux kernel:
https://github.com/NixOS/nixpkgs/issues/24485#issuecomment-429636677https://www.youtube.com/embed/QkcjCRE8Vvs?start=673&end=807&version=3
+
https://discussion.fedoraproject.org/t/disabling-selinux-breaks-docker-overlayfs/20232
MWEs + how to never write bug, start=264&end=294
Unfortunately there are really hard/impossible to reproduce bugs:
how to never write bug, start=294&end=319
If nothing works:
Specific to javascript, but valid for many other situations:
This kind of bug is scary:
TODO: test is
nix \ --extra-experimental-features 'nix-command flakes ca-derivations' \ realisation \ info \ github:NixOS/nixpkgs/58c85835512b0db938600b6fe13cc3e3dc4b364e#hello"aarch64-darwin"Darwin 22.3.0, macOS 13.2.1yesnonix-env (Nix) 2.10.2"nixpkgs"/nix/var/nix/profiles/per-user/root/channels/nixpkgs{"description":"A collection of packages for the Nix package manager","lastModified":1688392541,"locked":{"lastModified":1688392541,"narHash":"sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=","owner":"NixOS","repo":"nixpkgs","rev":"ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","type":"github"},"locks":{"nodes":{"root":{}},"root":"root","version":7},"original":{"id":"nixpkgs","type":"indirect"},"originalUrl":"flake:nixpkgs","path":"/nix/store/gmdhl9qfaic5765lxw2wj6hb2ifjmhjd-source","resolved":{"lastModified":1688392541,"narHash":"sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=","owner":"NixOS","repo":"nixpkgs","rev":"ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","type":"github"},"resolvedUrl":"github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","revision":"ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b","url":"github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b"}nix --extra-experimental-features 'nix-command flakes ca-derivations' realisation info github:NixOS/nixpkgs/nixpkgs-unstable#python3The rosetta thing
List:
The qemu-user-static thing
What name put here?
macOS to NixOS the Purely Functional Linux Distribution by Daniel Britten
Franz Pletz: NixOS, start=913&end=928, about homebrew vs nix
https://discourse.nixos.org/t/nixos-on-the-new-apple-macbook-m1/15715/2
Remember Mac uses
zsh(since when?):utmapp/UTM#2688 (comment)
MacOS Simple KVM
Part 1:
For some reason it is need to format the disk in the Disk Utility
?:
About the installer
TODO: try to test that
NixOS/nix#3616 (comment)
qemu
TODO: it documents part of history: https://stackoverflow.com/a/66887947
TODO: https://www.willhaley.com/blog/debian-arm-qemu/
nix \ build \ --no-write-lock-file \ --override-input nixpkgs github:nixos/nixpkgs/nixpkgs-unstable \ 'github:Mic92/nixos-aarch64-images#aarch64Image'curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-armhf/current/images/cdrom/initrd.gz \ && curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-armhf/current/images/cdrom/vmlinuz curl -O -L https://cdimage.debian.org/debian-cd/current/armhf/iso-dvd/debian-11.1.0-armhf-DVD-1.isohttps://www.willhaley.com/blog/debian-arm-qemu/
file $(nix --system aarch64-darwin build --no-link --print-out-paths --print-build-logs github:NixOS/nixpkgs/nixpkgs-unstable#qemu)/bin/qemu-system-aarch64 nix --system aarch64-darwin run github:NixOS/nixpkgs/nixpkgs-unstable#qemu -- --versionqemu + NixOS => build-vm
Excelent: Running qemu-system-aarch64 with -accel hvf on aarch64-darwin
Copying files like .img .qcow2
https://serverfault.com/a/670227
https://stackoverflow.com/questions/41733410/remove-qcow2-image-files-holes