{ config, lib, ... }: let nixpkgs = config.nixpkgs.source; conf = "${toString ../..}/configuration.nix"; rebuild = self: super: { nixos-rebuild = super.nixos-rebuild.overrideAttrs (old: { postInstall = old.postInstall + '' sed -i "$target" \ -e '/^export PATH/ a \ export NIX_PATH="nixpkgs=${nixpkgs}:nixos-config=${conf}"' \ -e 's/remoteSudo=/remoteSudo=1/' \ -e 's/-A system/-A system --no-out-link/' ''; }); }; in { options.nixpkgs.source = lib.mkOption { type = lib.types.path; description = "Nixpkgs sources"; }; config = { nixpkgs.pkgs = import nixpkgs { overlays = [ rebuild ]; }; nix.nixPath = [ "nixpkgs=/run/current-system/nixpkgs" "nixos-config=${conf}" ]; system.extraSystemBuilderCmds = "ln -s ${nixpkgs} $out/nixpkgs"; }; }