git.delta.rocks / jrsonnet / refs/heads / trunk

difftreelog

source

modules/nixos/top-level.nix2.3 KiBsourcehistory
1{2  pkgs,3  config,4  lib,5  ...6}:7let8  inherit (lib.strings) optionalString;9  # FIXME: Should not be copy-pasted, instead nixpkgs should export systemBuilder directly10  systemBuilder = ''11    mkdir $out1213    ${14      if config.boot.initrd.enable && config.boot.initrd.systemd.enable then15        ''16          # This must not be a symlink or the abs_path of the grub builder for the tests17          # will resolve the symlink and we end up with a path that doesn't point to a18          # system closure.19          cp "$systemd/lib/systemd/systemd" $out/init2021          ${lib.optionalString (!config.system.nixos-init.enable) ''22            cp ${config.system.build.bootStage2} $out/prepare-root23            substituteInPlace $out/prepare-root --subst-var-by systemConfig $out24          ''}25        ''26      else27        ''28          cp ${config.system.build.bootStage2} $out/init29          substituteInPlace $out/init --subst-var-by systemConfig $out30        ''31    }3233    ln -s ${config.system.build.etc}/etc $out/etc3435    ${lib.optionalString config.system.etc.overlay.enable ''36      ln -s ${config.system.build.etcMetadataImage} $out/etc-metadata-image37      ln -s ${config.system.build.etcBasedir} $out/etc-basedir38    ''}3940    ln -s ${config.system.path} $out/sw41    ln -s "$systemd" $out/systemd4243    echo -n "systemd ${toString config.systemd.package.interfaceVersion}" > $out/init-interface-version44    echo -n "$nixosLabel" > $out/nixos-version45    echo -n "${config.boot.kernelPackages.stdenv.hostPlatform.system}" > $out/system4647    ${config.system.systemBuilderCommands}4849    cp "$extraDependenciesPath" "$out/extra-dependencies"5051      ${config.boot.bootspec.writer}52      ${optionalString config.boot.bootspec.enableValidation ''${config.boot.bootspec.validator} "$out/${config.boot.bootspec.filename}"''}53  '';54in55{56  system.build.toplevel-fleet = pkgs.stdenvNoCC.mkDerivation (57    {58      name = "nixos-system-${config.system.name}-${config.system.nixos.label}";59      preferLocalBuild = true;60      allowSubstitutes = false;61      passAsFile = [ "extraDependencies" ];62      buildCommand = systemBuilder;6364      systemd = config.systemd.package;6566      nixosLabel = config.system.nixos.label;6768      inherit (config.system) extraDependencies;69    }70    // config.system.systemBuilderArgs71  );72}