Skip to content

Instantly share code, notes, and snippets.

@emilazy
Created March 22, 2020 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilazy/975aa88aec11685a67e737a53906770b to your computer and use it in GitHub Desktop.
Save emilazy/975aa88aec11685a67e737a53906770b to your computer and use it in GitHub Desktop.
{ sources ? import ./nix/sources.nix # do // { nixpkgs = ...; }
, nixos-config ? <nixos-config>
}:
let
eval = import (sources.nixpkgs + "/nixos/lib/eval-config.nix") {
system = builtins.currentSystem;
modules = [ nixos-config ];
specialArgs = { inherit sources; };
};
system = eval.config.system.build.toplevel;
inherit (eval) pkgs;
action = name: pkgs.writeShellScriptBin name ''
${pkgs.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set ${system}
# NIXOS_INSTALL_BOOTLOADER=1
${system}/bin/switch-to-configuration ${name}
'';
in
pkgs.symlinkJoin {
name = "switch-to-configuration";
paths = [
(action "boot")
(action "switch")
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment