nixos/virtualisation/google-compute-config: minor refactoring

Signed-off-by: lucasew <lucas59356@gmail.com>
This commit is contained in:
lucasew 2023-05-18 14:16:10 -03:00 committed by Anderson Torres
parent 971bf6ea22
commit 8587646ef3

View file

@ -1,5 +1,15 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let
inherit (lib)
boolToString
mkDefault
mkIf
optional
readFile
;
in
{ {
imports = [ imports = [
../profiles/headless.nix ../profiles/headless.nix
@ -65,7 +75,7 @@ with lib;
systemd.services.google-guest-agent = { systemd.services.google-guest-agent = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
restartTriggers = [ config.environment.etc."default/instance_configs.cfg".source ]; restartTriggers = [ config.environment.etc."default/instance_configs.cfg".source ];
path = lib.optional config.users.mutableUsers pkgs.shadow; path = optional config.users.mutableUsers pkgs.shadow;
}; };
systemd.services.google-startup-scripts.wantedBy = [ "multi-user.target" ]; systemd.services.google-startup-scripts.wantedBy = [ "multi-user.target" ];
systemd.services.google-shutdown-scripts.wantedBy = [ "multi-user.target" ]; systemd.services.google-shutdown-scripts.wantedBy = [ "multi-user.target" ];
@ -76,7 +86,7 @@ with lib;
users.groups.google-sudoers = mkIf config.users.mutableUsers { }; users.groups.google-sudoers = mkIf config.users.mutableUsers { };
boot.extraModprobeConfig = lib.readFile "${pkgs.google-guest-configs}/etc/modprobe.d/gce-blacklist.conf"; boot.extraModprobeConfig = readFile "${pkgs.google-guest-configs}/etc/modprobe.d/gce-blacklist.conf";
environment.etc."sysctl.d/60-gce-network-security.conf".source = "${pkgs.google-guest-configs}/etc/sysctl.d/60-gce-network-security.conf"; environment.etc."sysctl.d/60-gce-network-security.conf".source = "${pkgs.google-guest-configs}/etc/sysctl.d/60-gce-network-security.conf";