File tree 5 files changed +49
-57
lines changed
{% if docs %}docs{% endif %}/docs
5 files changed +49
-57
lines changed Original file line number Diff line number Diff line change 24
24
type = lib . types . str ;
25
25
} ;
26
26
27
+ storage = {
28
+ disks = {
29
+ main = {
30
+ device = lib . mkOption {
31
+ default = "/dev/sda" ;
32
+ description = "Device path of the main disk" ;
33
+ type = lib . types . str ;
34
+ } ;
35
+ } ;
36
+ } ;
37
+ } ;
38
+
27
39
vm = {
28
40
cpu = {
29
41
cores = lib . mkOption {
Original file line number Diff line number Diff line change 26
26
# Provide values to substitute
27
27
flake = inputs . self ;
28
28
host = config . constants . name ;
29
+ main = config . constants . storage . disks . main . device ;
29
30
}
30
31
) ;
31
32
} ;
Original file line number Diff line number Diff line change 4
4
5
5
FLAKE=' @flake@'
6
6
HOST=' @host@'
7
+ MAIN=' @main@'
7
8
8
9
# ## HELPER FUNCTIONS ###
9
10
10
11
print_usage () {
11
12
# Print script usage
12
13
13
14
cat << EOF
14
- Usage: $0 --main DEVICE [-k KEYFILE] [OPTIONS]
15
+ Usage: $0 [-k KEYFILE] [OPTIONS]
15
16
Install the system on this machine.
16
17
17
- --main path to the device with the main disk
18
18
-k, --keyfile path to the age key file
19
19
EOF
20
20
}
21
21
22
22
# ## PARSE ARGUMENTS ###
23
23
24
- main=' '
25
24
keyfile=" ${SOPS_AGE_KEY_FILE:- ${SOPS_AGE_KEY_DIR:- ${XDG_CONFIG_HOME:- ${HOME} / .config} / sops/ age} / keys.txt} "
26
25
unparsed=' '
27
26
28
27
while [[ -n ${1:- } ]]; do
29
28
case " $1 " in
30
- --main)
31
- shift
32
- main=" $1 "
33
- ;;
34
29
-k | --keyfile)
35
30
shift
36
31
keyfile=" $1 "
52
47
# shellcheck disable=SC2086
53
48
set -- ${unparsed}
54
49
55
- if [[ -z ${main} ]]; then
56
- printf ' %s\n' ' Error: --main is required.' >&2
57
- print_usage >&2
58
- exit 1
59
- fi
60
-
61
- if [[ ! -e ${main} ]]; then
62
- printf ' %s\n' " Error: Device ${main} does not exist." >&2
63
- print_usage >&2
64
- exit 2
65
- fi
66
-
67
50
if [[ ! -e ${keyfile} ]]; then
68
51
printf ' %s\n' " Error: Key file ${keyfile} does not exist." >&2
69
52
print_usage >&2
70
- exit 3
53
+ exit 1
71
54
fi
72
55
73
56
# ## MAIN ###
74
57
75
58
disko-install \
76
59
--flake " ${FLAKE} #${HOST} " \
77
- --disk main " ${main } " \
60
+ --disk main " ${MAIN } " \
78
61
--extra-files " ${keyfile} " /var/lib/sops/age/keys.txt \
79
62
--write-efi-boot-entries \
80
63
" $@ "
Original file line number Diff line number Diff line change 1
1
# Storage configuration
2
- { inputs , ...} : {
2
+ {
3
+ config ,
4
+ inputs ,
5
+ ...
6
+ } : {
3
7
imports = [
4
8
# Import Disko modules
5
9
inputs . disko . nixosModules . disko
10
14
disk = {
11
15
main = {
12
16
content = {
13
- # Use GPT partition table
14
- type = "gpt" ;
15
-
16
17
partitions = {
17
18
boot = {
18
- # Size of the boot partition
19
- size = "512M" ;
20
-
21
- # EFI system partition
22
- type = "EF00" ;
23
-
24
19
content = {
25
- # This partition contains a filesystem
26
- type = "filesystem" ;
27
-
28
20
# Format the partition as FAT
29
21
format = "vfat" ;
30
22
31
23
# Mount the partition at /boot
32
24
mountpoint = "/boot" ;
25
+
26
+ # This partition contains a filesystem
27
+ type = "filesystem" ;
33
28
} ;
29
+
30
+ # Size of the boot partition
31
+ size = "1G" ;
32
+
33
+ # EFI system partition
34
+ type = "EF00" ;
34
35
} ;
35
36
36
37
main = {
37
- # Use the rest of the disk for the main partition
38
- size = "100%" ;
39
-
40
38
content = {
41
- # This partition contains a filesystem
42
- type = "filesystem" ;
43
-
44
39
# Format the partition as ext4
45
40
format = "ext4" ;
46
41
47
42
# Mount the partition at /
48
43
mountpoint = "/" ;
44
+
45
+ # This partition contains a filesystem
46
+ type = "filesystem" ;
49
47
} ;
48
+
49
+ # Use the rest of the disk for the main partition
50
+ size = "100%" ;
51
+
52
+ # Linux filesystem partition
53
+ type = "8300" ;
50
54
} ;
51
55
} ;
56
+
57
+ # Use GPT partition table
58
+ type = "gpt" ;
52
59
} ;
60
+
61
+ device = config . constants . storage . disks . main . device ;
62
+ type = "disk" ;
53
63
} ;
54
64
} ;
55
65
} ;
Original file line number Diff line number Diff line change @@ -23,29 +23,15 @@ private keys on the target machine either in `~/.config/sops/age/keys.txt`
23
23
or somewhere else with `SOPS_AGE_KEY_FILE` environment variable set.
24
24
The installation script will copy the keys to persistent storage.
25
25
26
- Pick the host configuration you want to install
27
- and the devices for disks referenced in the configuration.
28
- For example, if you want to install the `dummy` host configuration
29
- and you have a single disk `/dev/sda`, run:
26
+ Change the HOST variable to the name of the host configuration
27
+ you want to install and run:
30
28
31
29
<!-- markdownlint-disable line-length -->
32
30
33
31
```sh
34
- sudo nix --experimental-features 'nix-command flakes' run github:{{ accountname }}/{{ reponame }}#dummy -install-script -- --main /dev/sda
32
+ sudo nix --experimental-features 'nix-command flakes' run " github:{{ accountname }}/{{ reponame }}#${HOST} -install-script"
35
33
```
36
34
37
35
<!-- markdownlint-enable line-length -->
38
36
39
37
and then reboot the machine.
40
-
41
- Installation scripts are customized for each host configuration.
42
- If you want more information about available options, use the `--help` flag.
43
- For example for the `dummy` host configuration:
44
-
45
- <!-- markdownlint-disable line-length -->
46
-
47
- ```sh
48
- sudo nix --experimental-features 'nix-command flakes' run github:{{ accountname }}/{{ reponame }}#dummy-install-script -- --help
49
- ```
50
-
51
- <!-- markdownlint-enable line-length -->
You can’t perform that action at this time.
0 commit comments