Skip to content

Commit adbd716

Browse files
SuperSandro2000astro
authored andcommitted
Use writeShellScript* to remove redundant shebang
1 parent a808af7 commit adbd716

File tree

7 files changed

+20
-35
lines changed

7 files changed

+20
-35
lines changed

doc/src/faq.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ does.
6464
environment.systemPackages = [ (
6565
# Provide a manual updating script that fetches the latest
6666
# updated+built system from Hydra
67-
pkgs.writeScriptBin "update-microvm" ''
68-
#! ${pkgs.runtimeShell} -e
69-
67+
pkgs.writeShellScriptBin "update-microvm" ''
7068
if [ $# -lt 1 ]; then
7169
NAMES="$(ls -1 /var/lib/microvms)"
7270
else

lib/runner.nix

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}:
55

66
let
7-
inherit (pkgs) lib writeScriptBin;
7+
inherit (pkgs) lib;
88

99
inherit (import ./. { nixpkgs-lib = lib; }) createVolumesScript makeMacvtap;
1010
inherit (makeMacvtap {
@@ -23,24 +23,20 @@ let
2323
execArg = lib.optionalString microvmConfig.prettyProcnames
2424
''-a "microvm@${microvmConfig.hostName}"'';
2525

26-
runScriptBin = pkgs.buildPackages.writeScriptBin "microvm-run" ''
27-
#! ${pkgs.runtimeShell} -e
28-
26+
runScriptBin = pkgs.buildPackages.writeShellScriptBin "microvm-run" ''
2927
${preStart}
3028
${createVolumesScript pkgs.buildPackages microvmConfig.volumes}
3129
${lib.optionalString (hypervisorConfig.requiresMacvtapAsFds or false) openMacvtapFds}
3230
3331
exec ${execArg} ${command}
3432
'';
3533

36-
shutdownScriptBin = pkgs.buildPackages.writeScriptBin "microvm-shutdown" ''
37-
#! ${pkgs.runtimeShell} -e
38-
34+
shutdownScriptBin = pkgs.buildPackages.writeShellScriptBin "microvm-shutdown" ''
3935
${shutdownCommand}
4036
'';
4137

42-
balloonScriptBin = pkgs.buildPackages.writeScriptBin "microvm-balloon" ''
43-
#! ${pkgs.runtimeShell} -e
38+
balloonScriptBin = pkgs.buildPackages.writeShellScriptBin "microvm-balloon" ''
39+
set -e
4440
4541
if [ -z "$1" ]; then
4642
echo "Usage: $0 <balloon-size-mb>"

nixos-modules/host/default.nix

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ in
137137
RemainAfterExit = true;
138138
ExecStop =
139139
let
140-
stopScript = pkgs.writeScript "stop-microvm-tap-interfaces" ''
141-
#! ${pkgs.runtimeShell} -e
142-
140+
stopScript = pkgs.writeShellScript "stop-microvm-tap-interfaces" ''
143141
cd ${stateDir}/$1
144142
for id in $(cat current/share/microvm/tap-interfaces); do
145143
${pkgs.iproute2}/bin/ip tuntap del name $id mode tap
@@ -176,8 +174,7 @@ in
176174
RemainAfterExit = true;
177175
ExecStop =
178176
let
179-
stopScript = pkgs.writeScript "stop-microvm-tap-interfaces" ''
180-
#! ${pkgs.runtimeShell} -e
177+
stopScript = pkgs.writeShellScript "stop-microvm-tap-interfaces" ''
181178
cd ${stateDir}/$1
182179
cat current/share/microvm/macvtap-interfaces | while read -r line;do
183180
opts=( $line )

nixos-modules/microvm/graphics.nix

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
let
44
# TODO: did not get sommelier to work
5-
run-sommelier = with pkgs; writeScriptBin "run-sommelier" ''
6-
#!${runtimeShell} -e
7-
exec ${sommelier}/bin/sommelier --virtgpu-channel -- $@
5+
run-sommelier = with pkgs; writeShellScriptBin "run-sommelier" ''
6+
exec ${lib.getExe sommelier} --virtgpu-channel -- $@
87
'';
98
# Working: run Wayland applications prefixed with `run-wayland-proxy`
10-
run-wayland-proxy = with pkgs; writeScriptBin "run-wayland-proxy" ''
11-
#!${runtimeShell} -e
12-
exec ${wayland-proxy-virtwl}/bin/wayland-proxy-virtwl --virtio-gpu -- $@
9+
run-wayland-proxy = with pkgs; writeShellScriptBin "run-wayland-proxy" ''
10+
exec ${lib.getExe wayland-proxy-virtwl} --virtio-gpu -- $@
1311
'';
1412
# Waypipe. Needs `microvm#waypipe-client` on the host.
15-
run-waypipe = with pkgs; writeScriptBin "run-waypipe" ''
16-
#!${runtimeShell} -e
17-
exec ${waypipe}/bin/waypipe --vsock -s 2:6000 server $@
13+
run-waypipe = with pkgs; writeShellScriptBin "run-waypipe" ''
14+
exec ${lib.getExe waypipe}/bin/waypipe --vsock -s 2:6000 server $@
1815
'';
1916
in
2017
lib.mkIf config.microvm.graphics.enable {

nixos-modules/microvm/ssh-deploy.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ in
9494

9595
# Implementations
9696
config.microvm.deploy = {
97-
installOnHost = pkgs.writeScriptBin "microvm-install-on-host" ''
97+
installOnHost = pkgs.writeShellScriptBin "microvm-install-on-host" ''
9898
set -eou pipefail
9999
100100
HOST="$1"
@@ -157,7 +157,7 @@ in
157157
'';
158158

159159
sshSwitch = lib.mkIf canSwitchViaSsh (
160-
pkgs.writeScriptBin "microvm-switch" ''
160+
pkgs.writeShellScriptBin "microvm-switch" ''
161161
set -eou pipefail
162162
163163
TARGET="$1"
@@ -186,7 +186,7 @@ in
186186
''
187187
);
188188

189-
rebuild = with config.microvm.deploy; pkgs.writeScriptBin "microvm-rebuild" ''
189+
rebuild = with config.microvm.deploy; pkgs.writeShellScriptBin "microvm-rebuild" ''
190190
set -eou pipefail
191191
192192
HOST="$1"

pkgs/build-microvm.nix

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
# local pkgs not from the target flake.
33
{ self
44
, lib, targetPlatform
5-
, writeScriptBin, runtimeShell
5+
, writeShellScriptBin
66
, coreutils, git, nix
77
}:
88

9-
writeScriptBin "build-microvm" ''
10-
#! ${runtimeShell} -e
11-
9+
writeShellScriptBin "build-microvm" ''
1210
PATH=${lib.makeBinPath [ coreutils git nix ]}
1311
1412
if [ $# -lt 1 ]; then

pkgs/microvm-command.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ let
1414
};
1515
colored = color: text: "${colors.${color}}${text}${colors.normal}";
1616
in
17-
writeScriptBin "microvm" ''
18-
#! ${pkgs.runtimeShell}
17+
writeShellScriptBin "microvm" ''
1918
set -e
2019
2120
PATH=${lib.makeBinPath [

0 commit comments

Comments
 (0)