Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3114b4586e2c
Choose a base ref
...
head repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 379f99e422c5
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Sep 20, 2020

  1. nixos-rebuild: add flake support for build-vm

    This relies on users using `nixpkgs.lib.nixosSystem` to define their
    system; otherwise, the `vm` and `vmWithBootLoader` attributes will not
    exist.
    
    (cherry picked from commit e26b348)
    cole-h authored and worldofpeace committed Sep 20, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    grahamc Graham Christensen
    Copy the full SHA
    379f99e View commit details
Showing with 29 additions and 7 deletions.
  1. +23 −3 flake.nix
  2. +6 −4 nixos/modules/installer/tools/nixos-rebuild.sh
26 changes: 23 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@

outputs = { self }:
let

jobs = import ./pkgs/top-level/release.nix {
nixpkgs = self;
};
@@ -28,10 +27,31 @@
lib = lib.extend (final: prev: {
nixosSystem = { modules, ... } @ args:
import ./nixos/lib/eval-config.nix (args // {
modules = modules ++
[ { system.nixos.versionSuffix =
modules =
let
vmConfig = (import ./nixos/lib/eval-config.nix
(args // {
modules = modules ++ [ ./nixos/modules/virtualisation/qemu-vm.nix ];
})).config;

vmWithBootLoaderConfig = (import ./nixos/lib/eval-config.nix
(args // {
modules = modules ++ [
./nixos/modules/virtualisation/qemu-vm.nix
{ virtualisation.useBootLoader = true; }
];
})).config;
in
modules ++ [
{
system.nixos.versionSuffix =
".${final.substring 0 8 (self.lastModifiedDate or self.lastModified)}.${self.shortRev or "dirty"}";
system.nixos.revision = final.mkIf (self ? rev) self.rev;

system.build = {
vm = vmConfig.system.build.vm;
vmWithBootLoader = vmWithBootLoaderConfig.system.build.vm;
};
}
];
});
10 changes: 6 additions & 4 deletions nixos/modules/installer/tools/nixos-rebuild.sh
Original file line number Diff line number Diff line change
@@ -438,15 +438,17 @@ if [ -z "$rollback" ]; then
if [[ -z $flake ]]; then
pathToConfig="$(nixBuild '<nixpkgs/nixos>' -A vm -k "${extraBuildFlags[@]}")"
else
echo "$0: 'build-vm' is not supported with '--flake'" >&2
exit 1
nix "${flakeFlags[@]}" build "$flake#$flakeAttr.config.system.build.vm" \
"${extraBuildFlags[@]}" "${lockFlags[@]}"
pathToConfig="$(readlink -f ./result)"
fi
elif [ "$action" = build-vm-with-bootloader ]; then
if [[ -z $flake ]]; then
pathToConfig="$(nixBuild '<nixpkgs/nixos>' -A vmWithBootLoader -k "${extraBuildFlags[@]}")"
else
echo "$0: 'build-vm-with-bootloader' is not supported with '--flake'" >&2
exit 1
nix "${flakeFlags[@]}" build "$flake#$flakeAttr.config.system.build.vmWithBootLoader" \
"${extraBuildFlags[@]}" "${lockFlags[@]}"
pathToConfig="$(readlink -f ./result)"
fi
else
showSyntax