{ vuizvuiSrc ? null , nixpkgsSrc ? , supportedSystems ? [ "i686-linux" "x86_64-linux" ] }: let nixpkgsRevCount = nixpkgsSrc.revCount or 12345; nixpkgsShortRev = nixpkgsSrc.shortRev or "abcdefg"; nixpkgsVersion = "pre${toString nixpkgsRevCount}.${nixpkgsShortRev}-vuizvui"; nixpkgs = nixpkgsSrc; vuizvuiRevCount = vuizvuiSrc.revCount or 12345; vuizvuiShortRev = vuizvuiSrc.shortRev or "abcdefg"; vuizvuiVersion = "pre${toString vuizvuiRevCount}.${vuizvuiShortRev}"; vuizvui = let patchedVuizvui = (import nixpkgs {}).stdenv.mkDerivation { name = "vuizvui-${vuizvuiVersion}"; inherit nixpkgsVersion; src = vuizvuiSrc; phases = [ "unpackPhase" "installPhase" ]; installPhase = '' cp -r --no-preserve=ownership "${nixpkgs}/" nixpkgs chmod -R u+w nixpkgs echo -n "$nixpkgsVersion" > nixpkgs/.version-suffix echo "echo '$nixpkgsVersion'" \ > nixpkgs/nixos/modules/installer/tools/get-version-suffix echo -n ${nixpkgs.rev or nixpkgsShortRev} > nixpkgs/.git-revision echo './nixpkgs' > nixpkgs-path.nix cp -r . "$out" ''; }; in if vuizvuiSrc == null then ./. else patchedVuizvui; system = "x86_64-linux"; pkgsUpstream = import nixpkgs { inherit system; }; root = import vuizvui { inherit system; }; mpath = if vuizvuiSrc == null then ./machines else "${vuizvui}/machines"; allMachines = import mpath; allTests = with import ./lib; getVuizvuiTests ({ inherit system nixpkgs; excludeVuizvuiGames = true; } // pkgsUpstream.lib.optionalAttrs (vuizvuiSrc != null) { vuizvuiTests = "${vuizvui}/tests"; }); pkgs = with pkgsUpstream.lib; let noGames = flip removeAttrs [ "games" ]; releaseLib = import "${nixpkgs}/pkgs/top-level/release-lib.nix" { inherit supportedSystems; packageSet = attrs: noGames (import vuizvui attrs).pkgs; }; packagePlatforms = mapAttrs (name: value: let platforms = value.meta.hydraPlatforms or (value.meta.platforms or []); isRecursive = value.recurseForDerivations or false || value.recurseForRelease or false; result = if isDerivation value then platforms else if isRecursive then packagePlatforms value else []; tried = builtins.tryEval result; in if tried.success then tried.value else []); in with releaseLib; mapTestOn (packagePlatforms releaseLib.pkgs); in with pkgsUpstream.lib; with builtins; { machines = let # We need to expose all the real builds within vuizvui.lazyPackages to make # sure they don't get garbage collected on the Hydra instance. wrapLazy = machine: pkgsUpstream.runCommand machine.build.name { fakeRuntimeDeps = machine.eval.config.vuizvui.lazyPackages; product = machine.build; } '' mkdir -p "$out/nix-support" echo "$product" > "$out/nix-support/fake-runtime-dependencies" for i in $fakeRuntimeDeps; do echo "$i" >> "$out/nix-support/fake-runtime-dependencies" done ''; in mapAttrsRecursiveCond (m: !(m ? eval)) (const wrapLazy) allMachines; isoImages = let buildIso = attrs: let name = attrs.iso.config.networking.hostName; cond = attrs.iso.config.vuizvui.createISO; in if !cond then {} else pkgsUpstream.runCommand "vuizvui-iso-${name}" { meta.description = "Live CD/USB stick of ${name}"; iso = attrs.iso.config.system.build.isoImage; passthru.config = attrs.iso.config; } '' mkdir -p "$out/nix-support" echo "file iso" $iso/iso/*.iso* \ >> "$out/nix-support/hydra-build-products" ''; in mapAttrsRecursiveCond (m: !(m ? iso)) (const buildIso) allMachines; tests = let machineList = collect (m: m ? eval) allMachines; activatedTests = unique (concatMap (machine: machine.eval.config.vuizvui.requiresTests ) machineList); mkTest = path: setAttrByPath path (getAttrFromPath path allTests); in fold recursiveUpdate {} (map mkTest activatedTests) // { inherit (allTests) vuizvui; }; inherit pkgs; channels = let mkChannel = attrs: root.pkgs.mkChannel (rec { name = "vuizvui-channel-${attrs.name or "generic"}-${vuizvuiVersion}"; src = vuizvui; patchPhase = '' touch .update-on-nixos-rebuild ''; } // removeAttrs attrs [ "name" ]); gatherTests = active: map (path: getAttrFromPath path allTests) active; in { generic = mkChannel { constituents = concatMap (collect isDerivation) [ allTests.vuizvui pkgs ]; }; machines = mapAttrsRecursiveCond (m: !(m ? eval)) (path: attrs: mkChannel { name = "machine-${last path}"; constituents = singleton attrs.eval.config.system.build.toplevel ++ gatherTests attrs.eval.config.vuizvui.requiresTests; }) allMachines; }; manual = let modules = import "${nixpkgs}/nixos/lib/eval-config.nix" { modules = import "${vuizvui}/modules/module-list.nix"; check = false; inherit system; }; patchedDocbookXSL = overrideDerivation pkgsUpstream.docbook5_xsl (drv: { # Don't chunk off postPatch = (drv.postPatch or "") + '' sed -i -e ' //d / "$out/nix-support/hydra-build-products" ''; }; }