{ config, pkgs, lib, inputs, ... }: let inherit (config.virtualisation) isVmVariant; inputUrls = lib.mapAttrs (input: value: value.url) (import (inputs.self + "/flake.nix")).inputs; in # TODO: make /etc/nixos a symlink to the in-store flake? - bad idea, horrible error recovery # TODO: make /etc/nixos a writeable checkout of repo? { system.autoUpgrade.enable = true; #system.autoUpgrade.allowReboot = true; # reboot after a kernel (module) or initrd upgrade, consider also setting `rebootWindow` environment.etc."current-system-flake".enable = !isVmVariant; # makes the outPath depend on flake src environment.etc."current-system-flake".source = inputs.self; # workaround for https://github.com/NixOS/nix/issues/6895 environment.etc."current-system-flake-inputs.json".enable = !isVmVariant; # makes the outPath depend on flake src environment.etc."current-system-flake-inputs.json".source = pkgs.writers.writeJSON "flake-inputs.json" ( lib.flip lib.mapAttrs inputs (name: input: # inputs.*.sourceInfo sans outPath, since writeJSON will otherwise serialize sourceInfo like derivation lib.filterAttrs (key: val: !builtins.elem key ["outPath"]) (input.sourceInfo or {}) // { store-path = builtins.unsafeDiscardStringContext input.outPath; } # use this line instead if you want to retain a store reference to the flake inputs, but don't make it a part of the closure # // { store-path = input.outPath; } # use this line instead if you want to retain a store reference to the flake inputs ) ); environment.etc."current-system-flake-inputs-overrides.sh".enable = !isVmVariant; environment.etc."current-system-flake-inputs-overrides.sh".source = pkgs.writeShellScript "with-input-overrides.sh" '' if [[ $# -eq 0 ]]; then echo >&2 "Example usage: $0 nix flake update --output-lock-file flake.lock" exit 1 fi set -euo pipefail declare -a cmd_args=() readarray -td $'\0' cmd_args < <( ${lib.getExe pkgs.jq} --raw-output0 \