Skip to content

Commit cc1aa71

Browse files
authored
Simplified configuration (#2)
1 parent 247b96d commit cc1aa71

File tree

35 files changed

+446
-755
lines changed

35 files changed

+446
-755
lines changed

src/CONTRIBUTING.md.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ If you want to try out any host configuration in a virtual machine,
161161
you can run:
162162

163163
```sh
164-
task run -- "./#$HOST-virtual-machine"
164+
task vm -- "$HOST"
165165
```
166166

167167
where `$HOST` is the name of the target machine.

src/Taskfile.dist.yaml.jinja

+15-14
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,27 @@ tasks:
144144
desc: Build a target
145145
cmds:
146146
- >
147-
nix
148-
--accept-flake-config
149-
--extra-experimental-features
150-
'nix-command flakes'
151-
--no-warn-dirty
152-
build
153-
--out-link
154-
build
147+
./scripts/build.sh
155148
{{ '{{ .CLI_ARGS }}' }}
156149
run:
157150
desc: Run a target
158151
interactive: true
159152
cmds:
160153
- >
161-
nix
162-
--accept-flake-config
163-
--extra-experimental-features
164-
'nix-command flakes'
165-
--no-warn-dirty
166-
run
154+
./scripts/run.sh
155+
{{ '{{ .CLI_ARGS }}' }}
156+
vm:
157+
desc: Run a virtual machine
158+
interactive: true
159+
cmds:
160+
- >
161+
./scripts/vm.sh
162+
{{ '{{ .CLI_ARGS }}' }}
163+
install:
164+
desc: Install system on current machine
165+
cmds:
166+
- >
167+
./scripts/install.sh
167168
{{ '{{ .CLI_ARGS }}' }}
168169
secret:
169170
desc: Edit secrets

src/flake.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/flake.nix.jinja

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
55
};
66

7+
disko = {
8+
url = "github:nix-community/disko";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
712
flake-parts = {
813
url = "github:hercules-ci/flake-parts";
914
};

src/scripts/build.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
### HELPER FUNCTIONS ###
4+
5+
print_usage() {
6+
# Print script usage
7+
8+
cat <<EOF
9+
Usage: $0 TARGET [OPTIONS]
10+
Build the specified target.
11+
EOF
12+
}
13+
14+
### PARSE ARGUMENTS ###
15+
16+
unparsed=''
17+
18+
while [[ -n ${1:-} ]]; do
19+
case "$1" in
20+
-h | --help)
21+
print_usage >&2
22+
exit
23+
;;
24+
--)
25+
shift
26+
unparsed="${unparsed} $*"
27+
break
28+
;;
29+
*) unparsed="${unparsed} $1" ;;
30+
esac
31+
shift
32+
done
33+
34+
# shellcheck disable=SC2086
35+
set -- ${unparsed}
36+
37+
target="$1"
38+
39+
if [[ -z ${target} ]]; then
40+
printf '%s\n' 'Error: TARGET is required.' >&2
41+
print_usage >&2
42+
exit 1
43+
fi
44+
45+
shift
46+
47+
### MAIN ###
48+
49+
nix \
50+
--accept-flake-config \
51+
--extra-experimental-features \
52+
'nix-command flakes' \
53+
--no-warn-dirty \
54+
build \
55+
--out-link \
56+
build \
57+
".#${target}" \
58+
"$@"

src/scripts/install.sh

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
### HELPER FUNCTIONS ###
4+
5+
print_usage() {
6+
# Print script usage
7+
8+
cat <<EOF
9+
Usage: $0 HOST [OPTIONS]
10+
Install the system for the specified host on the current machine.
11+
EOF
12+
}
13+
14+
### PARSE ARGUMENTS ###
15+
16+
unparsed=''
17+
18+
while [[ -n ${1:-} ]]; do
19+
case "$1" in
20+
-h | --help)
21+
print_usage >&2
22+
exit
23+
;;
24+
--)
25+
shift
26+
unparsed="${unparsed} $*"
27+
break
28+
;;
29+
*) unparsed="${unparsed} $1" ;;
30+
esac
31+
shift
32+
done
33+
34+
# shellcheck disable=SC2086
35+
set -- ${unparsed}
36+
37+
host="$1"
38+
39+
if [[ -z ${host} ]]; then
40+
printf '%s\n' 'Error: HOST is required.' >&2
41+
print_usage >&2
42+
exit 1
43+
fi
44+
45+
shift
46+
47+
### MAIN ###
48+
49+
if [[ ! -d "src/hosts/${host}" ]]; then
50+
printf '%s\n' "Error: ${host} is not a valid host." >&2
51+
exit 2
52+
fi
53+
54+
./scripts/run.sh "${host}-install-script" -- "$@"

src/scripts/run.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
### HELPER FUNCTIONS ###
4+
5+
print_usage() {
6+
# Print script usage
7+
8+
cat <<EOF
9+
Usage: $0 TARGET [OPTIONS]
10+
Run the specified target.
11+
EOF
12+
}
13+
14+
### PARSE ARGUMENTS ###
15+
16+
unparsed=''
17+
18+
while [[ -n ${1:-} ]]; do
19+
case "$1" in
20+
-h | --help)
21+
print_usage >&2
22+
exit
23+
;;
24+
--)
25+
shift
26+
unparsed="${unparsed} $*"
27+
break
28+
;;
29+
*) unparsed="${unparsed} $1" ;;
30+
esac
31+
shift
32+
done
33+
34+
# shellcheck disable=SC2086
35+
set -- ${unparsed}
36+
37+
target="$1"
38+
39+
if [[ -z ${target} ]]; then
40+
printf '%s\n' 'Error: TARGET is required.' >&2
41+
print_usage >&2
42+
exit 1
43+
fi
44+
45+
shift
46+
47+
### MAIN ###
48+
49+
nix \
50+
--accept-flake-config \
51+
--extra-experimental-features \
52+
'nix-command flakes' \
53+
--no-warn-dirty \
54+
run \
55+
".#${target}" \
56+
"$@"

src/scripts/vm.sh

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
### HELPER FUNCTIONS ###
4+
5+
print_usage() {
6+
# Print script usage
7+
8+
cat <<EOF
9+
Usage: $0 HOST [OPTIONS]
10+
Run a virtual machine for the specified host.
11+
EOF
12+
}
13+
14+
### PARSE ARGUMENTS ###
15+
16+
unparsed=''
17+
18+
while [[ -n ${1:-} ]]; do
19+
case "$1" in
20+
-h | --help)
21+
print_usage >&2
22+
exit
23+
;;
24+
--)
25+
shift
26+
unparsed="${unparsed} $*"
27+
break
28+
;;
29+
*) unparsed="${unparsed} $1" ;;
30+
esac
31+
shift
32+
done
33+
34+
# shellcheck disable=SC2086
35+
set -- ${unparsed}
36+
37+
host="$1"
38+
39+
if [[ -z ${host} ]]; then
40+
printf '%s\n' 'Error: HOST is required.' >&2
41+
print_usage >&2
42+
exit 1
43+
fi
44+
45+
shift
46+
47+
### MAIN ###
48+
49+
if [[ ! -d "src/hosts/${host}" ]]; then
50+
printf '%s\n' "Error: ${host} is not a valid host." >&2
51+
exit 2
52+
fi
53+
54+
./scripts/run.sh "${host}-virtual-machine" -- "$@"

src/src/hosts/dummy/modules/appearance/default.nix

-48
This file was deleted.

0 commit comments

Comments
 (0)