Skip to content

Commit

Permalink
move lenovo disko setup to a re-usuable module
Browse files Browse the repository at this point in the history
Signed-off-by: Jörg Thalheim <[email protected]>
  • Loading branch information
Mic92 authored and brianmcgillion committed Mar 12, 2024
1 parent 3e923f1 commit d7111d1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
18 changes: 18 additions & 0 deletions modules/common/hardware/definition.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
};
};

disks = mkOption {
description = "Disks to format and mount";
type = types.attrsOf (types.submodule {
options.device = mkOption {
type = types.str;
description = ''
Path to the disk
'';
};
});
default = {};
example = literalExpression ''
{
disk1.device = "/dev/nvme0n1";
}
'';
};

gpu = {
# TODO? Should add GuiVM enabler here?
# guivm.enable = mkEnableOption = "NetVM";
Expand Down
13 changes: 13 additions & 0 deletions modules/disko/flake-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
{inputs, ...}: {
flake.nixosModules = {
# TODO: rename this module to what it actually does rather than what model it's for.
# We version the disko partitiong module so that we can update it without breaking existing systems
disko-lenovo-x1-basic-v1.imports = [
inputs.disko.nixosModules.disko
./lenovo-x1-disko-basic.nix
./disko-basic-postboot.nix
];
};
}
2 changes: 2 additions & 0 deletions modules/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Modules to be exported from Flake
#
{inputs, ...}: {
imports = [./disko/flake-module.nix];

flake.nixosModules = {
common.imports = [
./common
Expand Down
9 changes: 3 additions & 6 deletions targets/lenovo-x1/everything.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
lib,
microvm,
lanzaboote,
disko,
name,
system,
...
Expand All @@ -24,7 +23,6 @@
inherit system;
modules =
[
disko.nixosModules.disko
lanzaboote.nixosModules.lanzaboote
microvm.nixosModules.host
self.nixosModules.common
Expand All @@ -33,10 +31,7 @@
self.nixosModules.lanzaboote
self.nixosModules.microvm

# TODO: Refactor the disko module a bit
../../modules/disko/lenovo-x1-disko-basic.nix #TODO define device in hw def file
{ disko.disk.disk1.device = "/dev/nvme0n1"; }
../../modules/disko/disko-basic-postboot.nix
self.nixosModules.disko-lenovo-x1-basic-v1

./sshkeys.nix
({
Expand Down Expand Up @@ -80,6 +75,8 @@
environment.etc.${config.ghaf.security.sshKeys.getAuthKeysFilePathInEtc} = import ./getAuthKeysSource.nix {inherit pkgs config;};
services.openssh = config.ghaf.security.sshKeys.sshAuthorizedKeysCommand;

disko.devices.disk = config.ghaf.hardware.definition.disks;

ghaf = {
hardware.definition = hwDefinition;
# To enable guest hardening enable host hardening first
Expand Down
2 changes: 2 additions & 0 deletions targets/lenovo-x1/hardwareDefinition.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
# Lenovo X1 trackpoint (red button/joystick)
"/dev/input/by-path/platform-i8042-serio-1-event-mouse"
];

disks.disk1.device = "/dev/nvme0n1";
}

0 comments on commit d7111d1

Please sign in to comment.