mirror of
https://github.com/nix-community/disko.git
synced 2024-09-17 09:37:17 +03:00
Merge pull request #56 from nix-community/cleanup
This commit is contained in:
commit
c60f20ceff
22
README.md
22
README.md
@ -48,7 +48,8 @@ TODO: output of the cli --help
|
|||||||
|
|
||||||
You can use the NixOS module in one of the following ways:
|
You can use the NixOS module in one of the following ways:
|
||||||
|
|
||||||
### Flakes
|
<details>
|
||||||
|
<summary>Flakes (Current recommendation)</summary>
|
||||||
|
|
||||||
If you use nix flakes support:
|
If you use nix flakes support:
|
||||||
|
|
||||||
@ -70,9 +71,11 @@ If you use nix flakes support:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
### [niv](https://github.com/nmattia/niv) (Current recommendation)
|
<details>
|
||||||
First add it to niv:
|
<summary>niv</summary>
|
||||||
|
|
||||||
|
First add it to [niv](https://github.com/nmattia/niv):
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ niv add nix-community/disko
|
$ niv add nix-community/disko
|
||||||
@ -85,8 +88,9 @@ $ niv add nix-community/disko
|
|||||||
imports = [ "${(import ./nix/sources.nix).disko}/modules/disko.nix" ];
|
imports = [ "${(import ./nix/sources.nix).disko}/modules/disko.nix" ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
### nix-channel
|
<details>
|
||||||
|
<summary>nix-channel</summary>
|
||||||
|
|
||||||
As root run:
|
As root run:
|
||||||
|
|
||||||
@ -102,8 +106,9 @@ $ nix-channel --update
|
|||||||
imports = [ <disko/modules/disko.nix> ];
|
imports = [ <disko/modules/disko.nix> ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
### fetchTarball
|
<details>
|
||||||
|
<summary>fetchTarball</summary>
|
||||||
|
|
||||||
Add the following to your configuration.nix:
|
Add the following to your configuration.nix:
|
||||||
|
|
||||||
@ -129,6 +134,7 @@ $ nix-channel --update
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
## Using the NixOS module
|
## Using the NixOS module
|
||||||
|
|
||||||
|
23
types.nix
23
types.nix
@ -51,21 +51,14 @@ rec {
|
|||||||
=> "/dev/disk/by-id/xxx-part2"
|
=> "/dev/disk/by-id/xxx-part2"
|
||||||
*/
|
*/
|
||||||
deviceNumbering = dev: index:
|
deviceNumbering = dev: index:
|
||||||
let
|
if match "/dev/[vs]d.+" dev != null then
|
||||||
schemas = {
|
dev + toString index # /dev/{s,v}da style
|
||||||
dev__da = dev + toString index; # /dev/{s,v}da style
|
else if match "/dev/disk/.+" dev != null then
|
||||||
dev_disk = "${dev}-part${toString index}"; # /dev/disk/by-id/xxx style
|
"${dev}-part${toString index}" # /dev/disk/by-id/xxx style
|
||||||
dev_nvme = "${dev}p${toString index}"; # /dev/nvme0n1p1 style
|
else if match "/dev/(nvme|md/|mmcblk).+" dev != null then
|
||||||
dev_md = "${dev}p${toString index}"; # /dev/nvme0n1p1 style
|
"${dev}p${toString index}" # /dev/nvme0n1p1 style
|
||||||
};
|
else
|
||||||
detectSchema =
|
abort "${dev} seems not to be a supported disk format";
|
||||||
if match "/dev/[vs]d.*" dev != null then "dev__da" else
|
|
||||||
if match "/dev/disk/.*" dev != null then "dev_disk" else
|
|
||||||
if match "/dev/nvme.*" dev != null then "dev_nvme" else
|
|
||||||
if match "/dev/md/.*" dev != null then "dev_md" else
|
|
||||||
if match "/dev/mmcblk.*" dev != null then "dev_nvme" else
|
|
||||||
abort "${dev} seems not to be a supported disk format";
|
|
||||||
in schemas.${detectSchema};
|
|
||||||
|
|
||||||
/* A nix option type representing a json datastructure, vendored from nixpkgs to avoid dependency on pkgs */
|
/* A nix option type representing a json datastructure, vendored from nixpkgs to avoid dependency on pkgs */
|
||||||
jsonType = let
|
jsonType = let
|
||||||
|
Loading…
Reference in New Issue
Block a user