Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion nixos/modules/hardware/cpu/amd-sev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ let
};
};
in
with lib;
{
options.hardware.cpu.amd.sev = optionsFor "SEV" "sev";

Expand Down
43 changes: 21 additions & 22 deletions nixos/modules/hardware/uni-sync.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
pkgs,
...
}:
with lib;
let
cfg = config.hardware.uni-sync;
in
{
meta.maintainers = with maintainers; [ yunfachi ];
meta.maintainers = with lib.maintainers; [ yunfachi ];

options.hardware.uni-sync = {
enable = mkEnableOption "udev rules and software for Lian Li Uni Controllers";
package = mkPackageOption pkgs "uni-sync" { };
enable = lib.mkEnableOption "udev rules and software for Lian Li Uni Controllers";
package = lib.mkPackageOption pkgs "uni-sync" { };

devices = mkOption {
devices = lib.mkOption {
default = [ ];
example = literalExpression ''
example = lib.literalExpression ''
[
{
device_id = "VID:1111/PID:11111/SN:1111111111";
Expand Down Expand Up @@ -53,23 +52,23 @@ in
]
'';
description = "List of controllers with their configurations.";
type = types.listOf (
types.submodule {
type = lib.types.listOf (
lib.types.submodule {
options = {
device_id = mkOption {
type = types.str;
device_id = lib.mkOption {
type = lib.types.str;
example = "VID:1111/PID:11111/SN:1111111111";
description = "Unique device ID displayed at each startup.";
};
sync_rgb = mkOption {
type = types.bool;
sync_rgb = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Enable ARGB header sync.";
};
channels = mkOption {
channels = lib.mkOption {
default = [ ];
example = literalExpression ''
example = lib.literalExpression ''
[
{
mode = "PWM";
Expand All @@ -89,20 +88,20 @@ in
]
'';
description = "List of channels connected to the controller.";
type = types.listOf (
types.submodule {
type = lib.types.listOf (
lib.types.submodule {
options = {
mode = mkOption {
type = types.enum [
mode = lib.mkOption {
type = lib.types.enum [
"Manual"
"PWM"
];
default = "Manual";
example = "PWM";
description = "\"PWM\" to enable PWM sync. \"Manual\" to set speed.";
};
speed = mkOption {
type = types.int;
speed = lib.mkOption {
type = lib.types.int;
default = "50";
example = "100";
description = "Fan speed as percentage (clamped between 0 and 100).";
Expand All @@ -117,8 +116,8 @@ in
};
};

config = mkIf cfg.enable {
environment.etc."uni-sync/uni-sync.json".text = mkIf (cfg.devices != [ ]) (
config = lib.mkIf cfg.enable {
environment.etc."uni-sync/uni-sync.json".text = lib.mkIf (cfg.devices != [ ]) (
builtins.toJSON { configs = cfg.devices; }
);

Expand Down
2 changes: 0 additions & 2 deletions nixos/modules/installer/netboot/netboot-base.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# This module contains the basic configuration for building netboot
# images

{ lib, ... }:

{
imports = [
./netboot.nix
Expand Down
19 changes: 8 additions & 11 deletions nixos/modules/installer/netboot/netboot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@
modulesPath,
...
}:

with lib;

{
imports = [
../../image/file-options.nix
];

options = {

netboot.squashfsCompression = mkOption {
netboot.squashfsCompression = lib.mkOption {
default = "zstd -Xcompression-level 19";
description = ''
Compression settings to use for the squashfs nix store.
'';
example = "zstd -Xcompression-level 6";
type = types.str;
type = lib.types.str;
};

netboot.storeContents = mkOption {
example = literalExpression "[ pkgs.stdenv ]";
netboot.storeContents = lib.mkOption {
example = lib.literalExpression "[ pkgs.stdenv ]";
description = ''
This option lists additional derivations to be included in the
Nix store in the generated netboot image.
Expand All @@ -42,14 +39,14 @@ with lib;
# here and it causes a cyclic dependency.
boot.loader.grub.enable = false;

fileSystems."/" = mkImageMediaOverride {
fileSystems."/" = lib.mkImageMediaOverride {
fsType = "tmpfs";
options = [ "mode=0755" ];
};

# In stage 1, mount a tmpfs on top of /nix/store (the squashfs
# image) to make this a live CD.
fileSystems."/nix/.ro-store" = mkImageMediaOverride {
fileSystems."/nix/.ro-store" = lib.mkImageMediaOverride {
fsType = "squashfs";
device = "../nix-store.squashfs";
options = [
Expand All @@ -59,13 +56,13 @@ with lib;
neededForBoot = true;
};

fileSystems."/nix/.rw-store" = mkImageMediaOverride {
fileSystems."/nix/.rw-store" = lib.mkImageMediaOverride {
fsType = "tmpfs";
options = [ "mode=0755" ];
neededForBoot = true;
};

fileSystems."/nix/store" = mkImageMediaOverride {
fileSystems."/nix/store" = lib.mkImageMediaOverride {
overlay = {
lowerdir = [ "/nix/.ro-store" ];
upperdir = "/nix/.rw-store/store";
Expand Down
81 changes: 39 additions & 42 deletions nixos/modules/installer/sd-card/sd-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
pkgs,
...
}:

with lib;

let
rootfsImage = pkgs.callPackage config.sdImage.rootFilesystemCreator (
{
Expand All @@ -28,17 +25,17 @@ let
populateImageCommands = config.sdImage.populateRootCommands;
volumeLabel = config.sdImage.rootVolumeLabel;
}
// optionalAttrs (config.sdImage.rootPartitionUUID != null) {
// lib.optionalAttrs (config.sdImage.rootPartitionUUID != null) {
uuid = config.sdImage.rootPartitionUUID;
}
);
in
{
imports = [
(mkRemovedOptionModule [ "sdImage" "bootPartitionID" ]
(lib.mkRemovedOptionModule [ "sdImage" "bootPartitionID" ]
"The FAT partition for SD image now only holds the Raspberry Pi firmware files. Use firmwarePartitionID to configure that partition's ID."
)
(mkRemovedOptionModule [ "sdImage" "bootSize" ]
(lib.mkRemovedOptionModule [ "sdImage" "bootSize" ]
"The boot files for SD image have been moved to the main ext4 partition. The FAT partition now only holds the Raspberry Pi firmware files. Changing its size may not be required."
)
(lib.mkRenamedOptionModuleWith {
Expand Down Expand Up @@ -68,16 +65,16 @@ in
];

options.sdImage = {
storePaths = mkOption {
type = with types; listOf package;
example = literalExpression "[ pkgs.stdenv ]";
storePaths = lib.mkOption {
type = lib.types.listOf lib.types.package;
example = lib.literalExpression "[ pkgs.stdenv ]";
description = ''
Derivations to be included in the Nix store in the generated SD image.
'';
};

firmwarePartitionOffset = mkOption {
type = types.int;
firmwarePartitionOffset = lib.mkOption {
type = lib.types.int;
default = 8;
description = ''
Gap in front of the /boot/firmware partition, in MiB (1024×1024 bytes).
Expand All @@ -91,34 +88,34 @@ in
'';
};

firmwarePartitionID = mkOption {
type = types.str;
firmwarePartitionID = lib.mkOption {
type = lib.types.str;
default = "0x2178694e";
description = ''
Volume ID for the /boot/firmware partition on the SD card. This value
must be a 32-bit hexadecimal number.
'';
};

firmwarePartitionName = mkOption {
type = types.str;
firmwarePartitionName = lib.mkOption {
type = lib.types.str;
default = "FIRMWARE";
description = ''
Name of the filesystem which holds the boot firmware.
'';
};

rootPartitionUUID = mkOption {
type = types.nullOr types.str;
rootPartitionUUID = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "14e19a7b-0ae0-484d-9d54-43bd6fdc20c7";
description = ''
UUID for the filesystem on the main NixOS partition on the SD card.
'';
};

rootVolumeLabel = mkOption {
type = types.str;
rootVolumeLabel = lib.mkOption {
type = lib.types.str;
default = "NIXOS_SD";
example = "NIXOS_PENDRIVE";
description = ''
Expand All @@ -128,10 +125,10 @@ in
'';
};

rootFilesystemCreator = mkOption {
type = types.oneOf [
types.package
types.path
rootFilesystemCreator = lib.mkOption {
type = lib.types.oneOf [
lib.types.package
lib.types.path
];
default = ../../../lib/make-ext4-fs.nix;
example = ''
Expand All @@ -142,35 +139,35 @@ in
'';
};

rootFilesystemImage = mkOption {
type = types.package;
rootFilesystemImage = lib.mkOption {
type = lib.types.package;
default = rootfsImage;
description = ''
The finished root partition image with all custom fileystem modifications.
Used to override the filesystem creator itself.
'';
};

firmwareSize = mkOption {
type = types.int;
firmwareSize = lib.mkOption {
type = lib.types.int;
# As of 2019-08-18 the Raspberry pi firmware + u-boot takes ~18MiB
default = 30;
description = ''
Size of the /boot/firmware partition, in megabytes.
'';
};

populateFirmwareCommands = mkOption {
example = literalExpression "'' cp \${pkgs.myBootLoader}/u-boot.bin firmware/ ''";
populateFirmwareCommands = lib.mkOption {
example = lib.literalExpression "'' cp \${pkgs.myBootLoader}/u-boot.bin firmware/ ''";
description = ''
Shell commands to populate the ./firmware directory.
All files in that directory are copied to the
/boot/firmware partition on the SD image.
'';
};

populateRootCommands = mkOption {
example = literalExpression "''\${config.boot.loader.generic-extlinux-compatible.populateCmd} -c \${config.system.build.toplevel} -d ./files/boot''";
populateRootCommands = lib.mkOption {
example = lib.literalExpression "''\${config.boot.loader.generic-extlinux-compatible.populateCmd} -c \${config.system.build.toplevel} -d ./files/boot''";
description = ''
Shell commands to populate the ./files directory.
All files in that directory are copied to the
Expand All @@ -179,34 +176,34 @@ in
'';
};

postBuildCommands = mkOption {
example = literalExpression "'' dd if=\${pkgs.myBootLoader}/SPL of=$img bs=1024 seek=1 conv=notrunc ''";
postBuildCommands = lib.mkOption {
example = lib.literalExpression "'' dd if=\${pkgs.myBootLoader}/SPL of=$img bs=1024 seek=1 conv=notrunc ''";
default = "";
description = ''
Shell commands to run after the image is built.
Can be used for boards requiring to dd u-boot SPL before actual partitions.
'';
};

compressImage = mkOption {
type = types.bool;
compressImage = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether the SD image should be compressed using
{command}`zstd`.
'';
};

expandOnBoot = mkOption {
type = types.bool;
expandOnBoot = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to configure the sd image to expand it's partition on boot.
'';
};

nixPathRegistrationFile = mkOption {
type = types.str;
nixPathRegistrationFile = lib.mkOption {
type = lib.types.str;
default = "/nix-path-registration";
description = ''
Location of the file containing the input for nix-store --load-db once the machine has booted.
Expand Down Expand Up @@ -285,11 +282,11 @@ in
''}

# Gap in front of the first partition, in MiB
gap=${toString config.sdImage.firmwarePartitionOffset}
gap=${lib.toString config.sdImage.firmwarePartitionOffset}

# Create the image file sized to fit /boot/firmware and /, plus slack for the gap.
rootSizeBlocks=$(du -B 512 --apparent-size $root_fs | awk '{ print $1 }')
firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
firmwareSizeBlocks=$((${lib.toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024))
truncate -s $imageSize $img

Expand All @@ -301,7 +298,7 @@ in
label-id: ${config.sdImage.firmwarePartitionID}

start=''${gap}M, size=$firmwareSizeBlocks, type=b
start=$((gap + ${toString config.sdImage.firmwareSize}))M, type=83, bootable
start=$((gap + ${lib.toString config.sdImage.firmwareSize}))M, type=83, bootable
EOF

# Copy the rootfs into the SD image
Expand Down
Loading
Loading