Skip to content

Commit 7f47758

Browse files
fix statix warnings
Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
1 parent 6bd5874 commit 7f47758

File tree

47 files changed

+1943
-1806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1943
-1806
lines changed

lib/builders/mkGhafConfiguration.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ let
7979
vmConfigModule = {
8080
ghaf.virtualization.vmConfig = vmConfig;
8181
};
82-
8382
# Module for extraConfig (wrapped properly)
8483
extraConfigModule = lib.optionalAttrs (extraConfig != { }) { ghaf = extraConfig; };
8584

@@ -143,7 +142,6 @@ let
143142

144143
# Full configuration name
145144
fullName = "${name}-${variant}";
146-
147145
# Determine the package output based on profile
148146
package =
149147
if profile == "orin" then

lib/builders/mkGhafInstaller.nix

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,40 @@ let
5858

5959
# Prevent the image from being included in the nix store
6060
# by explicitly excluding store contents
61-
isoImage.storeContents = [ ];
62-
6361
# Include the image file directly in the ISO filesystem (not in /nix/store)
6462
# This copies the file without creating a runtime dependency
6563
# Support both disko (disk1.raw.zst) and verity (ghaf-*.raw.zst) images
6664
# Use reflinks/hardlinks to avoid duplicating large image files
67-
isoImage.contents =
68-
let
69-
# Create a derivation that finds the .raw.zst file and creates a normalized reference
70-
# Using cp --reflink=auto attempts copy-on-write, falling back to hardlink
71-
normalizedImage = pkgs.runCommand "normalized-ghaf-image" { } ''
72-
mkdir -p $out
73-
# Find the .raw.zst file (either disk1.raw.zst or ghaf-*.raw.zst)
74-
imageFile=$(find ${imagePath} -maxdepth 1 -name "*.raw.zst" -type f | head -n 1)
75-
if [ -z "$imageFile" ]; then
76-
echo "Error: No .raw.zst file found in ${imagePath}" >&2
77-
exit 1
78-
fi
79-
# Use reflink if supported (e.g. btrfs), otherwise hardlink to avoid duplication
80-
# This saves significant disk space (6-7GB per installer build) compared to cp.
81-
cp --reflink=auto "$imageFile" $out/ghaf-image.raw.zst || \
82-
ln "$imageFile" $out/ghaf-image.raw.zst
83-
'';
84-
in
85-
[
86-
{
87-
source = "${normalizedImage}/ghaf-image.raw.zst";
88-
target = "/ghaf-image/ghaf-image.raw.zst";
89-
}
90-
];
65+
isoImage = {
66+
storeContents = [ ];
67+
68+
contents =
69+
let
70+
# Create a derivation that finds the .raw.zst file and creates a normalized reference
71+
# Using cp --reflink=auto attempts copy-on-write, falling back to hardlink
72+
normalizedImage = pkgs.runCommand "normalized-ghaf-image" { } ''
73+
mkdir -p $out
74+
# Find the .raw.zst file (either disk1.raw.zst or ghaf-*.raw.zst)
75+
imageFile=$(find ${imagePath} -maxdepth 1 -name "*.raw.zst" -type f | head -n 1)
76+
if [ -z "$imageFile" ]; then
77+
echo "Error: No .raw.zst file found in ${imagePath}" >&2
78+
exit 1
79+
fi
80+
# Use reflink if supported (e.g. btrfs), otherwise hardlink to avoid duplication
81+
# This saves significant disk space (6-7GB per installer build) compared to cp.
82+
cp --reflink=auto "$imageFile" $out/ghaf-image.raw.zst || \
83+
ln "$imageFile" $out/ghaf-image.raw.zst
84+
'';
85+
in
86+
[
87+
{
88+
source = "${normalizedImage}/ghaf-image.raw.zst";
89+
target = "/ghaf-image/ghaf-image.raw.zst";
90+
}
91+
];
92+
93+
squashfsCompression = "zstd -Xcompression-level 3";
94+
};
9195

9296
environment.sessionVariables = {
9397
IMG_PATH = "/iso/ghaf-image";
@@ -114,8 +118,6 @@ let
114118
'';
115119
};
116120

117-
isoImage.squashfsCompression = "zstd -Xcompression-level 3";
118-
119121
# NOTE: Stop nixos complains about "warning:
120122
# mdadm: Neither MAILADDR nor PROGRAM has been set. This will cause the `mdmon` service to crash."
121123
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/profiles/installation-device.nix#L112

lib/default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ in
6767
description = "Host name as string.";
6868
default = null;
6969
};
70+
7071
mac = lib.mkOption {
7172
type = lib.types.nullOr lib.types.str;
7273
description = "MAC address as string.";
@@ -88,11 +89,13 @@ in
8889
description = "The IPv4 subnet prefix length (e.g. 24 for 255.255.255.0)";
8990
example = 24;
9091
};
92+
9193
interfaceName = lib.mkOption {
9294
type = lib.types.nullOr lib.types.str;
9395
default = null;
9496
description = "Name of the network interface.";
9597
};
98+
9699
cid = lib.mkOption {
97100
type = lib.types.nullOr lib.types.int;
98101
default = null;

lib/global-config.nix

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ rec {
174174
};
175175
};
176176

177+
# Graphics/boot UI settings
178+
graphics = {
179+
boot = {
180+
enable = mkOption {
181+
type = types.bool;
182+
default = false;
183+
description = "Enable graphical boot support (splash screen, user login detection)";
184+
};
185+
};
186+
};
187+
177188
# IDS VM specific settings
178189
idsvm = {
179190
mitmproxy = {
@@ -356,34 +367,44 @@ rec {
356367
# Debug profile - full development/debugging capabilities
357368
debug = {
358369
debug.enable = true;
370+
359371
development = {
360372
ssh.daemon.enable = true;
361373
debug.tools.enable = true;
362374
nix-setup.enable = true;
363375
};
376+
364377
# Logging enabled with Ghaf's central logging infrastructure
365378
# Note: listener.address is auto-populated from admin-vm IP by
366379
# modules/common/global-config.nix (no need to set it per profile).
367380
logging = {
368381
enable = true;
369382
server.endpoint = "https://loki.ghaflogs.vedenemo.dev/loki/api/v1/push";
370383
};
384+
371385
security.audit.enable = false;
386+
372387
givc = {
373388
enable = true;
374389
# givc.debug disabled to allow logging (they conflict due to security)
375390
debug = false;
376391
};
392+
377393
services = {
378394
power-manager.enable = false;
379395
performance.enable = false;
380396
};
397+
381398
storage = {
382399
encryption.enable = false;
383400
storeOnDisk = false;
384401
};
402+
403+
graphics.boot.enable = true;
404+
385405
shm.enable = false;
386406
idsvm.mitmproxy.enable = false;
407+
387408
# Feature defaults for debug profile
388409
features = {
389410
fprint = {
@@ -416,27 +437,36 @@ rec {
416437
# Release profile - production settings
417438
release = {
418439
debug.enable = false;
440+
419441
development = {
420442
ssh.daemon.enable = false;
421443
debug.tools.enable = false;
422444
nix-setup.enable = false;
423445
};
446+
424447
logging.enable = false;
425448
security.audit.enable = true;
449+
426450
givc = {
427451
enable = true;
428452
debug = false;
429453
};
454+
430455
services = {
431456
power-manager.enable = true;
432457
performance.enable = true;
433458
};
459+
434460
storage = {
435461
encryption.enable = true;
436462
storeOnDisk = false;
437463
};
464+
465+
graphics.boot.enable = true;
466+
438467
shm.enable = false;
439468
idsvm.mitmproxy.enable = false;
469+
440470
# Feature defaults for release profile
441471
features = {
442472
fprint = {
@@ -469,27 +499,34 @@ rec {
469499
# Minimal profile - bare minimum
470500
minimal = {
471501
debug.enable = false;
502+
472503
development = {
473504
ssh.daemon.enable = false;
474505
debug.tools.enable = false;
475506
nix-setup.enable = false;
476507
};
508+
477509
logging.enable = false;
478510
security.audit.enable = false;
511+
479512
givc = {
480513
enable = false;
481514
debug = false;
482515
};
516+
483517
services = {
484518
power-manager.enable = false;
485519
performance.enable = false;
486520
};
521+
487522
storage = {
488523
encryption.enable = false;
489524
storeOnDisk = false;
490525
};
526+
491527
shm.enable = false;
492528
idsvm.mitmproxy.enable = false;
529+
493530
# Feature defaults for minimal profile - all disabled
494531
features = {
495532
fprint = {
@@ -606,7 +643,6 @@ rec {
606643

607644
# Kernel configuration for this VM type (if defined)
608645
kernel = config.ghaf.kernel.${vmType} or null;
609-
610646
# QEMU configuration for this VM type (if defined)
611647
qemu = config.ghaf.qemu.${vmType} or null;
612648

@@ -622,7 +658,6 @@ rec {
622658

623659
# Host filesystem paths
624660
sharedVmDirectory = config.ghaf.virtualization.microvm-host.sharedVmDirectory or null;
625-
626661
# Boot configuration
627662
microvmBoot = {
628663
enable = config.ghaf.microvm-boot.enable or false;
@@ -632,10 +667,8 @@ rec {
632667
hardware = {
633668
devices = config.ghaf.hardware.devices or { };
634669
};
635-
636670
# Common namespace (for killswitch, etc.)
637671
common = config.ghaf.common or { };
638-
639672
# User configuration (complex, kept as-is for now)
640673
users = config.ghaf.users or { };
641674

@@ -664,7 +697,6 @@ rec {
664697
# AppVM configurations (needed by guivm for launcher generation)
665698
# Use enabledVms which has derived values including applications from vmDef
666699
appvms = config.ghaf.virtualization.microvm.appvm.enabledVms or { };
667-
668700
# GUIVM applications (needed by guivm for local launcher generation)
669701
guivm = {
670702
applications = config.ghaf.virtualization.microvm.guivm.applications or [ ];

modules/common/identity/dynamic-hostname.nix

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -280,27 +280,46 @@ in
280280
};
281281

282282
config = mkIf cfg.enable {
283-
systemd.tmpfiles.rules = [
284-
"d ${toString cfg.outputDir} 0755 root root - -"
285-
"d ${toString cfg.shareDir} 0755 root root - -"
286-
"d /persist/common 0755 root root - -"
287-
];
288-
289-
systemd.services.ghaf-dynamic-hostname = {
290-
description = "Compute and export dynamic host identity and transient hostname";
291-
wantedBy = [ "multi-user.target" ];
292-
after = [
293-
"local-fs.target"
294-
"sysinit.target"
295-
];
296-
before = [
297-
"multi-user.target"
298-
"network-online.target"
283+
systemd = {
284+
tmpfiles.rules = [
285+
"d ${toString cfg.outputDir} 0755 root root - -"
286+
"d ${toString cfg.shareDir} 0755 root root - -"
287+
"d /persist/common 0755 root root - -"
299288
];
300-
serviceConfig = {
301-
Type = "oneshot";
302-
ExecStart = "${computeScript}/bin/ghaf-compute-hostname";
303-
RemainAfterExit = true;
289+
290+
services.ghaf-dynamic-hostname = {
291+
description = "Compute and export dynamic host identity and transient hostname";
292+
wantedBy = [ "multi-user.target" ];
293+
after = [
294+
"local-fs.target"
295+
"sysinit.target"
296+
];
297+
before = [
298+
"multi-user.target"
299+
"network-online.target"
300+
];
301+
serviceConfig = {
302+
Type = "oneshot";
303+
ExecStart = "${computeScript}/bin/ghaf-compute-hostname";
304+
RemainAfterExit = true;
305+
306+
# Set systemd environment for services
307+
ExecStartPost =
308+
let
309+
setHostnameEnv = pkgs.writeShellApplication {
310+
name = "set-hostname-env";
311+
runtimeInputs = [ pkgs.systemd ];
312+
text = ''
313+
if [ -r ${toString cfg.outputDir}/hostname ]; then
314+
if command -v systemctl >/dev/null 2>&1; then
315+
systemctl set-environment GHAF_HOSTNAME="$(cat ${toString cfg.outputDir}/hostname)"
316+
fi
317+
fi
318+
'';
319+
};
320+
in
321+
"${setHostnameEnv}/bin/set-hostname-env";
322+
};
304323
};
305324
};
306325

@@ -311,22 +330,5 @@ in
311330
export GHAF_HOSTNAME_FILE="/run/ghaf-hostname"
312331
fi
313332
'';
314-
315-
# Set systemd environment for services
316-
systemd.services.ghaf-dynamic-hostname.serviceConfig.ExecStartPost =
317-
let
318-
setHostnameEnv = pkgs.writeShellApplication {
319-
name = "set-hostname-env";
320-
runtimeInputs = [ pkgs.systemd ];
321-
text = ''
322-
if [ -r ${toString cfg.outputDir}/hostname ]; then
323-
if command -v systemctl >/dev/null 2>&1; then
324-
systemctl set-environment GHAF_HOSTNAME="$(cat ${toString cfg.outputDir}/hostname)"
325-
fi
326-
fi
327-
'';
328-
};
329-
in
330-
"${setHostnameEnv}/bin/set-hostname-env";
331333
};
332334
}

0 commit comments

Comments
 (0)