mirror of
https://github.com/nix-community/disko.git
synced 2024-09-11 06:25:33 +03:00
nix fmt
This commit is contained in:
parent
35d4378e74
commit
9f5d4e45cd
@ -93,8 +93,8 @@ A simple disko configuration may look like this:
|
||||
```
|
||||
|
||||
If you'd saved this configuration in /tmp/disk-config.nix, and wanted to create
|
||||
a disk named /dev/sda, you would run the following command to partition,
|
||||
format and mount the disk.
|
||||
a disk named /dev/sda, you would run the following command to partition, format
|
||||
and mount the disk.
|
||||
|
||||
```console
|
||||
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/disk-config.nix
|
||||
|
@ -70,8 +70,8 @@ and made a note of its URL.
|
||||
Your configuration needs to be saved on the new machine for example
|
||||
as /tmp/disk-config.nix. You can do this using the `curl` command to download
|
||||
from the url you noted above, using the `-o` option to save the file as
|
||||
disk-config.nix. Your commands would look like this if you had chosen the
|
||||
hybrid layout:
|
||||
disk-config.nix. Your commands would look like this if you had chosen the hybrid
|
||||
layout:
|
||||
|
||||
```console
|
||||
cd /tmp
|
||||
@ -182,8 +182,8 @@ of the NixOS manual. The following configuration for `grub` works for both EFI
|
||||
and BIOS systems. Add this to your configuration.nix, commenting out the
|
||||
existing lines that configure `systemd-boot`. The entries will look like this:
|
||||
|
||||
**Note:** Its not necessary to set `boot.loader.grub.device` here, since Disko will
|
||||
take care of that automatically.
|
||||
**Note:** Its not necessary to set `boot.loader.grub.device` here, since Disko
|
||||
will take care of that automatically.
|
||||
|
||||
```nix
|
||||
# ...
|
||||
|
@ -51,9 +51,11 @@ generate disk images:
|
||||
|
||||
### Generating the `.raw` VM Image
|
||||
|
||||
1. **Create a NixOS configuration that includes the disko and the disk configuration of your choice**
|
||||
1. **Create a NixOS configuration that includes the disko and the disk
|
||||
configuration of your choice**
|
||||
|
||||
In the this example we create a flake containing a nixos configuration for `myhost`.
|
||||
In the this example we create a flake containing a nixos configuration for
|
||||
`myhost`.
|
||||
|
||||
```nix
|
||||
# save this as flake.nix
|
||||
@ -86,15 +88,15 @@ In the this example we create a flake containing a nixos configuration for `myho
|
||||
}
|
||||
```
|
||||
|
||||
2. **Build the disko image script:** Replace `myhost` in the command below with your
|
||||
specific system configuration name:
|
||||
2. **Build the disko image script:** Replace `myhost` in the command below with
|
||||
your specific system configuration name:
|
||||
|
||||
```console
|
||||
nix build .#nixosConfigurations.myhost.config.system.build.diskoImagesScript
|
||||
```
|
||||
|
||||
3. **Execute the disko image script:** Execute the generated disko image script. Running
|
||||
`./result --help` will output the available options:
|
||||
3. **Execute the disko image script:** Execute the generated disko image script.
|
||||
Running `./result --help` will output the available options:
|
||||
|
||||
```console
|
||||
./result --help
|
||||
@ -124,9 +126,10 @@ In the this example we create a flake containing a nixos configuration for `myho
|
||||
sudo ./result --build-memory 2048
|
||||
```
|
||||
|
||||
The script will generate the actual image outside of the nix store in the current working directory.
|
||||
The create image names depend on the names used in `disko.devices.disk` attrset in the NixOS configuration.
|
||||
In our code example it will produce the following image:
|
||||
The script will generate the actual image outside of the nix store in the
|
||||
current working directory. The create image names depend on the names used in
|
||||
`disko.devices.disk` attrset in the NixOS configuration. In our code example it will
|
||||
produce the following image:
|
||||
|
||||
```
|
||||
$ ls -la vdb.raw
|
||||
@ -142,8 +145,8 @@ In the this example we create a flake containing a nixos configuration for `myho
|
||||
```
|
||||
|
||||
- If the `.raw` image size is not optimal, use `--write-to-disk` to write
|
||||
directly to a drive. This bypasses the `.raw` file generation, which saves on read/write operations
|
||||
and is suitable for single disk setups.
|
||||
directly to a drive. This bypasses the `.raw` file generation, which saves on
|
||||
read/write operations and is suitable for single disk setups.
|
||||
|
||||
### Understanding the Image Generation Process
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
{
|
||||
disko = pkgs.callPackage ./package.nix { };
|
||||
# alias to make `nix run` more convenient
|
||||
disko-install = self.packages.${system}.disko.overrideAttrs (old: {
|
||||
disko-install = self.packages.${system}.disko.overrideAttrs (_old: {
|
||||
name = "disko-install";
|
||||
});
|
||||
default = self.packages.${system}.disko;
|
||||
|
@ -245,14 +245,17 @@ let
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = diskoLib.jsonType;
|
||||
default = lib.mapAttrsRecursive (name: value: if builtins.isString value then ''
|
||||
default = lib.mapAttrsRecursive
|
||||
(_name: value:
|
||||
if builtins.isString value then ''
|
||||
(
|
||||
${diskoLib.indent (diskoLib.defineHookVariables { inherit options; })}
|
||||
${config.preMountHook}
|
||||
${diskoLib.indent value}
|
||||
${config.postMountHook}
|
||||
)
|
||||
'' else value) attrs.default;
|
||||
'' else value)
|
||||
attrs.default;
|
||||
description = "Mount script";
|
||||
};
|
||||
|
||||
|
@ -114,7 +114,8 @@ let
|
||||
};
|
||||
|
||||
installedTopLevel = ((if extendModules != null then extendModules else installed-system-eval.extendModules) {
|
||||
modules = [({config, ...}: {
|
||||
modules = [
|
||||
({ config, ... }: {
|
||||
imports = [
|
||||
extraSystemConfig
|
||||
({ modulesPath, ... }: {
|
||||
@ -154,7 +155,8 @@ let
|
||||
'';
|
||||
}
|
||||
];
|
||||
})];
|
||||
})
|
||||
];
|
||||
}).config.system.build.toplevel;
|
||||
|
||||
in
|
||||
|
@ -55,12 +55,14 @@ in
|
||||
};
|
||||
label = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = let
|
||||
default =
|
||||
let
|
||||
# 72 bytes is the maximum length of a GPT partition name
|
||||
# the labels seem to be in UTF-16, so 2 bytes per character
|
||||
limit = 36;
|
||||
label = "${config._parent.type}-${config._parent.name}-${partition.config.name}";
|
||||
in if (lib.stringLength label) > limit then
|
||||
in
|
||||
if (lib.stringLength label) > limit then
|
||||
builtins.substring 0 limit (builtins.hashString "sha256" label)
|
||||
else
|
||||
label;
|
||||
@ -95,7 +97,7 @@ in
|
||||
};
|
||||
content = diskoLib.partitionType { parent = config; device = partition.config.device; };
|
||||
hybrid = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.submodule ({name, ...} @ hp: {
|
||||
type = lib.types.nullOr (lib.types.submodule ({ ... } @ hp: {
|
||||
options = {
|
||||
mbrPartitionType = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
|
@ -119,7 +119,8 @@
|
||||
++ lib.optional (lv.lvm_type == "raid0") "raid0"
|
||||
++ lib.optional (lv.lvm_type == "raid1") "raid1"
|
||||
# ++ lib.optional (lv.lvm_type == "raid10") "raid10"
|
||||
++ lib.optional (lv.lvm_type == "raid4" ||
|
||||
++ lib.optional
|
||||
(lv.lvm_type == "raid4" ||
|
||||
lv.lvm_type == "raid5" ||
|
||||
lv.lvm_type == "raid6") "raid456";
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
If you encounter errors similar to:
|
||||
"error: The option `disko.devices.disk.disk1.content.partitions."[definition 1-entry 1]".content._config` is read-only, but it's set multiple times,"
|
||||
this is likely due to the use of the legacy table type.
|
||||
'' {
|
||||
''
|
||||
{
|
||||
type = lib.mkOption {
|
||||
type = lib.types.enum [ "table" ];
|
||||
internal = true;
|
||||
|
@ -52,7 +52,8 @@
|
||||
description = "Metadata";
|
||||
};
|
||||
|
||||
_create = diskoLib.mkCreateOption {
|
||||
_create = diskoLib.mkCreateOption
|
||||
{
|
||||
inherit config options;
|
||||
# -u prevents mounting newly created datasets, which is
|
||||
# important to prevent accidental shadowing of mount points
|
||||
|
Loading…
Reference in New Issue
Block a user