mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
add support for another mountpoint than /mnt
This commit is contained in:
parent
d7e178126f
commit
af2da574be
6 changed files with 40 additions and 19 deletions
2
cli.nix
2
cli.nix
|
@ -3,10 +3,12 @@
|
|||
, flake ? null
|
||||
, flakeAttr ? null
|
||||
, diskoFile ? null
|
||||
, rootMountPoint ? "/mnt"
|
||||
, noDeps ? false
|
||||
, ... }@args:
|
||||
let
|
||||
disko = import ./. {
|
||||
inherit rootMountPoint;
|
||||
lib = pkgs.lib;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{ lib ? import <nixpkgs/lib> }:
|
||||
{ lib ? import <nixpkgs/lib>
|
||||
, rootMountPoint ? "/mnt"
|
||||
}:
|
||||
let
|
||||
types = import ./types.nix { inherit lib; };
|
||||
types = import ./types.nix { inherit lib rootMountPoint; };
|
||||
eval = cfg: lib.evalModules {
|
||||
modules = lib.singleton {
|
||||
# _file = toString input;
|
||||
|
|
8
disko
8
disko
|
@ -25,6 +25,8 @@ Options:
|
|||
pass value to nix-build. can be used to set disk-names for example
|
||||
* --argstr name value
|
||||
pass value to nix-build as string
|
||||
* --root-mountpoint /mnt
|
||||
where to mount the device tree
|
||||
* --dry-run
|
||||
just show the path to the script instead of running it
|
||||
* --debug
|
||||
|
@ -54,7 +56,7 @@ while [[ $# -gt 0 ]]; do
|
|||
shift
|
||||
;;
|
||||
-f | --flake)
|
||||
flake="$2"
|
||||
flake=$2
|
||||
shift
|
||||
;;
|
||||
--argstr | --arg)
|
||||
|
@ -69,6 +71,10 @@ while [[ $# -gt 0 ]]; do
|
|||
--dry-run)
|
||||
dry_run=y
|
||||
;;
|
||||
--root-mountpoint)
|
||||
nix_args+=(--arg rootMountPoint "$2")
|
||||
shift
|
||||
;;
|
||||
--no-deps)
|
||||
nix_args+=(--arg noDeps true)
|
||||
;;
|
||||
|
|
5
doc.nix
5
doc.nix
|
@ -1,7 +1,10 @@
|
|||
{ lib, nixosOptionsDoc, runCommand, fetchurl, pandoc }:
|
||||
|
||||
let
|
||||
types = import ./types.nix { inherit lib; };
|
||||
types = import ./types.nix {
|
||||
inherit lib;
|
||||
rootMountPoint = "/mnt";
|
||||
};
|
||||
eval = lib.evalModules {
|
||||
modules = [
|
||||
{
|
||||
|
|
10
module.nix
10
module.nix
|
@ -1,6 +1,9 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
types = import ./types.nix { inherit lib; };
|
||||
types = import ./types.nix {
|
||||
inherit lib;
|
||||
rootMountPoint = config.disko.rootMountPoint;
|
||||
};
|
||||
cfg = config.disko;
|
||||
in {
|
||||
options.disko = {
|
||||
|
@ -9,6 +12,11 @@ in {
|
|||
default = {};
|
||||
description = "The devices to set up";
|
||||
};
|
||||
rootMountPoint = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/mnt";
|
||||
description = "Where the device tree should be mounted by the mountScript";
|
||||
};
|
||||
enableConfig = lib.mkOption {
|
||||
description = ''
|
||||
configure nixos with the specified devices
|
||||
|
|
28
types.nix
28
types.nix
|
@ -1,4 +1,4 @@
|
|||
{ lib }:
|
||||
{ lib, rootMountPoint }:
|
||||
with lib;
|
||||
with builtins;
|
||||
|
||||
|
@ -223,7 +223,7 @@ rec {
|
|||
*/
|
||||
zapCreateMount = devices: ''
|
||||
set -efux
|
||||
umount -Rv /mnt || :
|
||||
umount -Rv "${rootMountPoint}" mnt || :
|
||||
|
||||
for dev in ${toString (lib.catAttrs "device" (lib.attrValues devices.disk))}; do
|
||||
${./disk-deactivate}/disk-deactivate "$dev" | bash -x
|
||||
|
@ -354,8 +354,8 @@ rec {
|
|||
inherit config options;
|
||||
default = {}: {
|
||||
fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${config.fsType} "/mnt${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount -t ${config.fsType} ${config.device} "/mnt${config.mountpoint}" \
|
||||
if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount -t ${config.fsType} ${config.device} "${rootMountPoint}${config.mountpoint}" \
|
||||
${concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
-o X-mount.mkdir
|
||||
fi
|
||||
|
@ -434,8 +434,8 @@ rec {
|
|||
in {
|
||||
fs = subvolMounts.fs // optionalAttrs (!isNull config.mountpoint) {
|
||||
${config.mountpoint} = ''
|
||||
if ! findmnt ${dev} "/mnt${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "/mnt${config.mountpoint}" \
|
||||
if ! findmnt ${dev} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "${rootMountPoint}${config.mountpoint}" \
|
||||
${concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
-o X-mount.mkdir
|
||||
fi
|
||||
|
@ -524,8 +524,8 @@ rec {
|
|||
else null;
|
||||
in optionalAttrs (!isNull mountpoint) {
|
||||
fs.${mountpoint} = ''
|
||||
if ! findmnt ${dev} "/mnt${mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "/mnt${mountpoint}" \
|
||||
if ! findmnt ${dev} "${rootMountPoint}${mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "${rootMountPoint}${mountpoint}" \
|
||||
${concatMapStringsSep " " (opt: "-o ${opt}") (config.mountOptions ++ [ "subvol=${config.name}" ])} \
|
||||
-o X-mount.mkdir
|
||||
fi
|
||||
|
@ -603,8 +603,8 @@ rec {
|
|||
inherit config options;
|
||||
default = {dev}: {
|
||||
fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${dev} "/mnt${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "/mnt${config.mountpoint}" \
|
||||
if ! findmnt ${dev} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${dev} "${rootMountPoint}${config.mountpoint}" \
|
||||
-t "${config.format}" \
|
||||
${concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
-o X-mount.mkdir
|
||||
|
@ -1169,8 +1169,8 @@ rec {
|
|||
'';
|
||||
fs = datasetMounts.fs // optionalAttrs (!isNull config.mountpoint) {
|
||||
${config.mountpoint} = ''
|
||||
if ! findmnt ${config.name} "/mnt${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${config.name} "/mnt${config.mountpoint}" \
|
||||
if ! findmnt ${config.name} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${config.name} "${rootMountPoint}${config.mountpoint}" \
|
||||
${optionalString ((config.options.mountpoint or "") != "legacy") "-o zfsutil"} \
|
||||
${concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
-o X-mount.mkdir \
|
||||
|
@ -1273,8 +1273,8 @@ rec {
|
|||
default = {zpool}:
|
||||
optionalAttrs (config.zfs_type == "volume" && !isNull config.content) (config.content._mount {dev = "/dev/zvol/${zpool}/${config.name}";}) //
|
||||
optionalAttrs (config.zfs_type == "filesystem" && config.options.mountpoint or "" != "none") { fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${zpool}/${config.name} "/mnt${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${zpool}/${config.name} "/mnt${config.mountpoint}" \
|
||||
if ! findmnt ${zpool}/${config.name} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount ${zpool}/${config.name} "${rootMountPoint}${config.mountpoint}" \
|
||||
-o X-mount.mkdir \
|
||||
${concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
${optionalString ((config.options.mountpoint or "") != "legacy") "-o zfsutil"} \
|
||||
|
|
Loading…
Reference in a new issue