117 days ago · Tech · hide · Fediverse post

Here's how to create a Nix closure archive within a Nix derivation. This uses the binary-cache function in the nixpkgs repository. # Save as flake.nix { description = "Nix binary cache demo"; inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-26.05"; inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, flake-utils, }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system}; modulePath = "${pkgs.path}/pkgs/build-support/binary-cache/default.nix"; mkBinaryModule = import modulePath; mkBinaryCache = pkgs.callPackage mkBinaryModule { }; rootPaths = [ pkgs.hello ]; in { packages.default = mkBinaryCache { inherit rootPaths; }; } ); } How the script works pkgs.path gives you the Nix store path to nixpkgs for your current system. See: $ nix eval nixpkgs#path /nix/store//9fig…-source/ The modulePath variable "${pkgs.path}/pkgs/build-support/binary-cache/default.nix" evaluates to the following:…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town