File tree 7 files changed +64
-45
lines changed
src/src/hosts/dummy/modules
7 files changed +64
-45
lines changed Original file line number Diff line number Diff line change 6
6
availableKernelModules = [
7
7
# These were autodetected by nixos-generate-config
8
8
"ahci"
9
- "xhci_pci"
10
- "virtio_pci"
11
9
"sr_mod"
10
+ "virtio_pci"
12
11
"virtio_blk"
12
+ "xhci_pci"
13
13
] ;
14
14
} ;
15
15
Original file line number Diff line number Diff line change 24
24
type = lib . types . str ;
25
25
} ;
26
26
27
+ secrets = {
28
+ sops = {
29
+ age = {
30
+ file = lib . mkOption {
31
+ default = "/var/lib/sops/age/keys.txt" ;
32
+ description = "Path to the file with private age keys" ;
33
+ type = lib . types . str ;
34
+ } ;
35
+ } ;
36
+ } ;
37
+ } ;
38
+
27
39
storage = {
28
40
disks = {
29
41
main = {
Original file line number Diff line number Diff line change 1
1
# Install script
2
2
{
3
- inputs ,
4
3
config ,
4
+ inputs ,
5
5
lib ,
6
6
pkgs ,
7
7
...
8
- } : {
9
- options = {
10
- installScript = lib . mkOption {
11
- # Create shell script
12
- default = pkgs . writeShellApplication {
13
- # Name of the script
14
- name = "install" ;
8
+ } : let
9
+ script = pkgs . writeShellApplication {
10
+ # Name of the script
11
+ name = "install" ;
15
12
16
- # Packages available in the script
17
- runtimeInputs = [ pkgs . coreutils pkgs . disko ] ;
13
+ # Packages available in the script
14
+ runtimeInputs = [ pkgs . coreutils pkgs . disko ] ;
18
15
19
- # Load the script with substituted values
20
- text = builtins . readFile (
21
- # Substitute values in the script
22
- pkgs . substituteAll {
23
- # Use this file as source
24
- src = ./install.sh ;
16
+ # Load the script with substituted values
17
+ text = builtins . readFile (
18
+ # Substitute values in the script
19
+ pkgs . substituteAll {
20
+ # Use this file as source
21
+ src = ./install.sh ;
25
22
26
- # Provide values to substitute
27
- flake = inputs . self ;
28
- host = config . constants . name ;
29
- main = config . constants . storage . disks . main . device ;
30
- }
31
- ) ;
32
- } ;
23
+ # Provide values to substitute
24
+ flake = inputs . self ;
25
+ host = config . constants . name ;
26
+ keysFile = config . constants . secrets . sops . age . file ;
27
+ mainDiskDevice = config . constants . storage . disks . main . device ;
28
+ }
29
+ ) ;
30
+ } ;
31
+ in {
32
+ options = {
33
+ installScript = lib . mkOption {
34
+ default = script ;
33
35
} ;
34
36
} ;
35
37
}
Original file line number Diff line number Diff line change 4
4
5
5
FLAKE=' @flake@'
6
6
HOST=' @host@'
7
- MAIN=' @main@'
7
+ KEYS_FILE=' @keysFile@'
8
+ MAIN_DISK_DEVICE=' @mainDiskDevice@'
8
9
9
10
# ## HELPER FUNCTIONS ###
10
11
11
12
print_usage () {
12
13
# Print script usage
13
14
14
15
cat << EOF
15
- Usage: $0 [-k KEYFILE ] [OPTIONS]
16
+ Usage: $0 [-k KEYSFILE ] [OPTIONS]
16
17
Install the system on this machine.
17
18
18
- -k, --keyfile path to the age key file
19
+ -k, --keysfile path to the age keys file
19
20
EOF
20
21
}
21
22
22
23
# ## PARSE ARGUMENTS ###
23
24
24
- keyfile =" ${SOPS_AGE_KEY_FILE:- ${SOPS_AGE_KEY_DIR:- ${XDG_CONFIG_HOME:- ${HOME} / .config} / sops/ age} / keys.txt} "
25
+ keysfile =" ${SOPS_AGE_KEY_FILE:- ${SOPS_AGE_KEY_DIR:- ${XDG_CONFIG_HOME:- ${HOME} / .config/ } / sops/ age/ } / keys.txt} "
25
26
unparsed=' '
26
27
27
28
while [[ -n ${1:- } ]]; do
28
29
case " $1 " in
29
- -k | --keyfile )
30
+ -k | --keysfile )
30
31
shift
31
- keyfile =" $1 "
32
+ keysfile =" $1 "
32
33
;;
33
34
-h | --help)
34
35
print_usage >&2
47
48
# shellcheck disable=SC2086
48
49
set -- ${unparsed}
49
50
50
- if [[ ! -e ${keyfile } ]]; then
51
- printf ' %s\n' " Error: Key file ${keyfile } does not exist." >&2
51
+ if [[ ! -e ${keysfile } ]]; then
52
+ printf ' %s\n' " Error: Keys file ${keysfile } does not exist." >&2
52
53
print_usage >&2
53
54
exit 1
54
55
fi
57
58
58
59
disko-install \
59
60
--flake " ${FLAKE} #${HOST} " \
60
- --disk main " ${MAIN } " \
61
- --extra-files " ${keyfile } " /var/lib/sops/age/keys.txt \
61
+ --disk main " ${MAIN_DISK_DEVICE } " \
62
+ --extra-files " ${keysfile } " " ${KEYS_FILE} " \
62
63
--write-efi-boot-entries \
63
64
" $@ "
Original file line number Diff line number Diff line change 3
3
nix = {
4
4
settings = {
5
5
experimental-features = [
6
- # Enable commands
7
- "nix-command"
8
-
9
6
# Enable flakes
10
7
"flakes"
8
+
9
+ # Enable commands
10
+ "nix-command"
11
11
] ;
12
12
} ;
13
13
} ;
Original file line number Diff line number Diff line change 1
1
# Secrets configuration
2
- { inputs , ...} : {
2
+ {
3
+ config ,
4
+ inputs ,
5
+ ...
6
+ } : {
3
7
imports = [
4
8
# Import sops modules
5
9
inputs . sops-nix . nixosModules . sops
8
12
sops = {
9
13
age = {
10
14
# age private keys should be stored at this path on the host
11
- keyFile = "/var/lib/ sops/ age/keys.txt" ;
15
+ keyFile = config . constants . secrets . sops . age . file ;
12
16
13
17
# This is needed so that ssh keys are not unnecessarily picked up
14
18
sshKeyPaths = [ ] ;
Original file line number Diff line number Diff line change 27
27
28
28
# Shared directories between the virtual machine and your development machine
29
29
sharedDirectories = {
30
- # This is needed to transmit your age private key to the virtual machine
31
- age-key = {
32
- # The private key should be stored at this path on your development machine
33
- source = "\ ${SOPS_AGE_KEY_DIR:-\ ${XDG_CONFIG_HOME:-$HOME/.config}/sops/age}" ;
30
+ # This is needed to transmit your age private keys to the virtual machine
31
+ sops- age-keys = {
32
+ # The private keys should be stored at this path on your development machine
33
+ source = "\ ${SOPS_AGE_KEY_DIR:-\ ${XDG_CONFIG_HOME:-$HOME/.config/ }/sops/age/ }" ;
34
34
35
35
# And will be mounted in the virtual machine at this path
36
- target = "/var/lib/ sops/ age" ;
36
+ target = builtins . dirOf config . constants . secrets . sops . age . file ;
37
37
} ;
38
38
} ;
39
39
} ;
You can’t perform that action at this time.
0 commit comments