Copying Nix Flake inputs to a different machine
Simple one-liner to avoid re-downloading inputs on a different machine on your LAN
Simple one-liner to avoid re-downloading inputs on a different machine on your LAN
In Nix it is possible to replace a call to builtins.map with lib.catAttrs if the transformation is just pulling out a field. For example: builtins.map (item: item.field) list can instead just be catAttrs "field" list.
Nix CLI’s flake info subcommand is great to find duplicate inputs, nix-melt is too much manual labor.
In a Nix REPL you can run :bl inputs.nixpkgs.legacyPackages.aarch64-linux.pkgs.attic-server to build the derivation and create a result link. Can also run :bl nixosConfigurations.ryzenbox.pkgs.attic-client.
Nix remote builds are run through the daemon (obviously) so they are executed as root on the host delegating builds. To prevent issues, nix store ping needs to be run as root first to verify the host key before Nix can start using the remote host to do builds.
Nix’s builtins.toString doesn’t stringify a Boolean directly but instead returns an empty string for false and "1" for true. The reason for this is apparently that the result is optimized for use in shell pipelines, so the result is expected to go into a [ -z $result ] on the result of calling the function. Lost entirely too much time to this.
Nixpkgs has a pkgs.mkBinaryCache helper that lets you create a flat-file binary cache suitable for moving around without needing a server component.
Found this awesome reference for the NixOS module system: https://nix.dev/tutorials/module-system/index.html
Nix vendors Golang dependencies in a fixed-output derivation (FOD) which will give confusing errors if the contents change but you don’t update the hash or name. Concrete example: refreshing the update-tailscale.patch file for caddy-tailscale will fail with mysterious “this module is using a different version” until you change either pname or vendorHash to force a rebuild of the FOD and reveal any real errors.
The nix-update CLI allows updating unstable packages to Git commits via --version=branch