1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 19:23:01 +03:00
mobile-nixos/modules/generated-filesystems.nix

93 lines
2.5 KiB
Nix
Raw Normal View History

# Generated filesystems, contrary to filesystems on a configured system.
#
# This contains the machinery to produce filesystem images.
{ config, lib, pkgs, ...}:
let
inherit (lib) types;
filesystemFunctions = {
"ext4" = pkgs.imageBuilder.fileSystem.makeExt4;
};
filesystemSubmodule =
{ name, config, ... }: {
options = {
type = lib.mkOption {
type = types.enum [ "ext4" ];
description = ''
Type of the generated filesystem.
'';
};
label = lib.mkOption {
type = types.str;
description = ''
The label used by the generated rootfs, when generating a rootfs, and
the filesystem label a Mobile NixOS system will look for by default.
'';
};
id = lib.mkOption {
type = types.str;
description = ''
The UUID used by the generated rootfs, when generating a rootfs.
'';
};
populateCommands = lib.mkOption {
type = types.lines;
description = ''
Commands used to fill the filesystem.
`$PWD` is the root of the filesystem.
'';
};
postProcess = lib.mkOption {
type = types.lines;
internal = true;
description = ''
Commands used to manipulate the filesystem after it has been
created.
'';
};
extraPadding = lib.mkOption {
type = types.int;
description = ''
Extra padding to add to the filesystem image.
'';
};
zstd = lib.mkOption {
internal = true;
type = types.bool;
description = ''
Whether to compress this artifact; used to work around size
limitations in CI situations.
'';
};
};
config = {
};
}
;
in
{
options = {
mobile.generatedFilesystems = lib.mkOption {
type = types.attrsOf (types.submodule filesystemSubmodule);
description = ''
Filesystem definitions that will be created at build.
'';
};
};
config = {
system.build.generatedFilesystems = lib.attrsets.mapAttrs (name: {type, id, label, ...} @ attrs:
filesystemFunctions."${type}" (attrs // {
name = label;
partitionID = id;
})
) config.mobile.generatedFilesystems;
# Compatibility alias with the previous path.
system.build.rootfs = config.system.build.generatedFilesystems.rootfs;
};
}