summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2023-01-02 10:36:41 -0500
committerGitHub <noreply@github.com>2023-01-02 07:36:41 -0800
commit15013b305466fdd0a52222ed2a3ff87bf9e41af9 (patch)
treee786abcad8e79d92312e533cd97f8e40f6caf2cb /nixos
parentf18a89197a3eca7859a1ac15a21f58b76994ee18 (diff)
downloadnixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.tar
nixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.tar.gz
nixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.tar.bz2
nixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.tar.lz
nixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.tar.xz
nixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.tar.zst
nixpkgs-15013b305466fdd0a52222ed2a3ff87bf9e41af9.zip
darwin.builder: prefer shutting down over halting VM (#208450)
This is preferable because it prevents things like disk corruption (requiring the user to delete the disk image when starting up) that I consistently ran into.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/profiles/macos-builder.nix30
1 files changed, 21 insertions, 9 deletions
diff --git a/nixos/modules/profiles/macos-builder.nix b/nixos/modules/profiles/macos-builder.nix
index a981814730a..fddf19ad125 100644
--- a/nixos/modules/profiles/macos-builder.nix
+++ b/nixos/modules/profiles/macos-builder.nix
@@ -9,7 +9,8 @@ let
 
 in
 
-{ imports = [
+{
+  imports = [
     ../virtualisation/qemu-vm.nix
 
     # Avoid a dependency on stateVersion
@@ -18,8 +19,7 @@ in
         ../virtualisation/nixos-containers.nix
         ../services/x11/desktop-managers/xterm.nix
       ];
-      config = {
-      };
+      config = { };
       options.boot.isContainer = lib.mkOption { default = false; internal = true; };
     }
   ];
@@ -98,11 +98,11 @@ in
       '';
 
     in
-      script.overrideAttrs (old: {
-        meta = (old.meta or { }) // {
-          platforms = lib.platforms.darwin;
-        };
-      });
+    script.overrideAttrs (old: {
+      meta = (old.meta or { }) // {
+        platforms = lib.platforms.darwin;
+      };
+    });
 
   system = {
     # To prevent gratuitous rebuilds on each change to Nixpkgs
@@ -118,10 +118,22 @@ in
     '');
   };
 
-  users.users."${user}"= {
+  users.users."${user}" = {
     isNormalUser = true;
   };
 
+  security.polkit.enable = true;
+
+  security.polkit.extraConfig = ''
+    polkit.addRule(function(action, subject) {
+      if (action.id === "org.freedesktop.login1.power-off" && subject.user === "${user}") {
+        return "yes";
+      } else {
+        return "no";
+      }
+    })
+  '';
+
   virtualisation = {
     diskSize = 20 * 1024;