Create mount script in fileSystems
module
This commit is contained in:
parent
8d56d55a05
commit
85a4989837
2 changed files with 30 additions and 31 deletions
|
@ -41,8 +41,13 @@ in
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
|
|
||||||
fileSystems = {
|
fileSystems = {
|
||||||
|
rootDir = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The root of the installation directory to mount disks into.";
|
||||||
|
default = "/mnt";
|
||||||
|
};
|
||||||
|
|
||||||
mounts = mkOption {
|
mounts = mkOption {
|
||||||
type = types.attrsOf mountType;
|
type = types.attrsOf mountType;
|
||||||
description = "The devices to mount.";
|
description = "The devices to mount.";
|
||||||
|
@ -63,6 +68,25 @@ in
|
||||||
script =
|
script =
|
||||||
let
|
let
|
||||||
devices = (builtins.attrValues cfg.diskSetup.devices);
|
devices = (builtins.attrValues cfg.diskSetup.devices);
|
||||||
|
mountScript = lib.strings.concatLines (
|
||||||
|
(builtins.concatMap
|
||||||
|
(
|
||||||
|
_: [
|
||||||
|
"partprobe 2> /dev/null || true"
|
||||||
|
"udevadm trigger"
|
||||||
|
(builtins.concatStringsSep " " (
|
||||||
|
[ "sudo" "mount" "--mkdir" ] ++
|
||||||
|
(lib.optionals (_.fsType == "ntfs") [ "-t" "ntfs3" ]) ++
|
||||||
|
[
|
||||||
|
(builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.options))
|
||||||
|
(_.device)
|
||||||
|
(lib.strings.normalizePath "/${cfg.diskSetup.rootDir}/${_.mountPoint}")
|
||||||
|
]
|
||||||
|
))
|
||||||
|
]
|
||||||
|
)
|
||||||
|
(builtins.attrValues cfg.mounts))
|
||||||
|
);
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
@ -80,7 +104,8 @@ in
|
||||||
''
|
''
|
||||||
])}
|
])}
|
||||||
${cfg.diskSetup.scripts.partition}
|
${cfg.diskSetup.scripts.partition}
|
||||||
${cfg.diskSetup.scripts.mount}
|
${mountScript}
|
||||||
|
${cfg.diskSetup.scripts.swap}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -298,12 +298,6 @@ in
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
fileSystems = {
|
fileSystems = {
|
||||||
rootDir = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "The root of the installation directory to mount disks into.";
|
|
||||||
default = "/mnt";
|
|
||||||
};
|
|
||||||
|
|
||||||
diskSetup = {
|
diskSetup = {
|
||||||
devices = mkOption {
|
devices = mkOption {
|
||||||
type = types.attrsOf (mkDeviceType);
|
type = types.attrsOf (mkDeviceType);
|
||||||
|
@ -322,9 +316,9 @@ in
|
||||||
description = "The script for partitioning the disks.";
|
description = "The script for partitioning the disks.";
|
||||||
};
|
};
|
||||||
|
|
||||||
mount = mkOption {
|
swap = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "The script for mounting the partitioned disks.";
|
description = "The script for enabling swap devices.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -356,8 +350,6 @@ in
|
||||||
diskSetup = {
|
diskSetup = {
|
||||||
scripts =
|
scripts =
|
||||||
let
|
let
|
||||||
inherit (cfg) rootDir;
|
|
||||||
inherit (lib.strings) normalizePath;
|
|
||||||
partPath = part: "/dev/disk/by-label/${part.label}";
|
partPath = part: "/dev/disk/by-label/${part.label}";
|
||||||
disks = ((builtins.attrValues cfg.diskSetup.devices));
|
disks = ((builtins.attrValues cfg.diskSetup.devices));
|
||||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||||
|
@ -365,25 +357,7 @@ in
|
||||||
{
|
{
|
||||||
init = lib.strings.concatLines (builtins.map (_: _.scripts.init) disks);
|
init = lib.strings.concatLines (builtins.map (_: _.scripts.init) disks);
|
||||||
partition = lib.strings.concatLines (builtins.map (_: _.scripts.partition) disks);
|
partition = lib.strings.concatLines (builtins.map (_: _.scripts.partition) disks);
|
||||||
mount = lib.strings.concatLines (
|
swap = lib.strings.concatLines (
|
||||||
(builtins.concatMap
|
|
||||||
(
|
|
||||||
_: [
|
|
||||||
probeScript
|
|
||||||
(builtins.concatStringsSep " " (
|
|
||||||
[ "sudo" "mount" "--mkdir" ] ++
|
|
||||||
(lib.optionals (_.format == "ntfs") [ "-t" "ntfs3" ]) ++
|
|
||||||
[
|
|
||||||
(builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.mountOptions))
|
|
||||||
(partPath _)
|
|
||||||
(normalizePath "/${rootDir}/${_.mountPoint}")
|
|
||||||
]
|
|
||||||
))
|
|
||||||
]
|
|
||||||
)
|
|
||||||
(lib.lists.sortOn
|
|
||||||
(_: normalizePath "/${_.mountPoint}")
|
|
||||||
(builtins.filter (_: _.mountPoint != null) partitions))) ++
|
|
||||||
(builtins.map
|
(builtins.map
|
||||||
(
|
(
|
||||||
_: ''
|
_: ''
|
||||||
|
|
Loading…
Reference in a new issue