Snippet #2345 (by symphorien, yaml)

  • #2345
Expires in: 0 minutes View Raw
  1. #builder.sh:
  2. #   #!/bin/sh
  3. #   <$file $bsdgames/bin/rot13 > $out
  4.  
  5. with import <nixpkgs> {};
  6.  
  7. let
  8.  squashfsTools = pkgs.squashfsTools.override { lz4Support = true; };
  9.  mkSquashFs = settings: contents: stdenv.mkDerivation {
  10.    name = "squashfs.img";
  11.    nativeBuildInputs = [ squashfsTools ];
  12.    buildCommand = ''
  13.      closureInfo=${closureInfo { rootPaths = contents; }}
  14.      mksquashfs $(cat $closureInfo/store-paths) $out \
  15.        -keep-as-directory -all-root -b 1048576 ${settings}
  16.    '';
  17.  };
  18.  
  19.  mkSquashFsLz4 = mkSquashFs "-comp lz4 -Xhc";
  20.  image = mkSquashFsLz4 [ bash ];
  21.  rot13 = file: derivation {
  22.    name = file.name + "-rot13";
  23.    inherit file;
  24.    bsdgames = pkgsi686Linux.bsdgames;
  25.    system = builtins.currentSystem;
  26.    builder = ./builder.sh;
  27.    allowedReferences = [];
  28.    preferLocalBuild = true;
  29.  };
  30. in
  31.  rot13 (rot13 image)
  32.  
  33. # the first rot13 derivation has no reference
  34. # the second will scan for references among its inputs:
  35. # * (rot13 image) which has no references
  36. # * 32 bit bsdgames and its deps
  37. # This will build iff the squash image does not reference any of the runtime
  38. # dependencies of the 32bit bsdgame. That's why I use a 32 bit bsdgames, otherwise
  39. # they have glibc in common.

Reply to this snippet →

Honeypot, don't fill.
⌘+⏎ or Ctrl+⏎