1 hour ago · Tech · hide · 0 comments

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:…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.