Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created October 18, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/d535a4bd6a1a7a013e88d8aa29bfdf58 to your computer and use it in GitHub Desktop.
Save cleverca22/d535a4bd6a1a7a013e88d8aa29bfdf58 to your computer and use it in GitHub Desktop.
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs { config = {}; overlays = []; };
paths = [ pkgs.hello ];
in {
closure = pkgs.runCommand "closure" {
buildInputs = with pkgs; [ nix mktorrent ];
closureInfo = pkgs.closureInfo { rootPaths = paths; };
} ''
export NIX_STATE_DIR=$NIX_BUILD_TOP/state
nix-store --load-db < $closureInfo/registration
nix copy --to file:///$NIX_BUILD_TOP/cache $(cat $closureInfo/store-paths)
ls $NIX_BUILD_TOP/cache -lh
mktorrent --output=whatever.torrent --no-date --web-seed=http://whatever $NIX_BUILD_TOP/cache
mkdir -p $out
mv -vi whatever.torrent $out/
# option 1
cat > $out/upload <<EOF
#!/bin/sh
nix sign-paths --key-file "\$2" -r ${toString paths}
nix copy --to "\$1" ${toString paths}
EOF
chmod +x $out/upload
# option 2
mv -vi $NIX_BUILD_TOP/cache $out/
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment