Skip to content

Commit 0b9284d

Browse files
Cleaning statix warnings
Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
1 parent 47bc804 commit 0b9284d

File tree

12 files changed

+398
-349
lines changed

12 files changed

+398
-349
lines changed

modules/common/services/xdghandlers.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ in
7474
xdgOpenFile
7575
];
7676

77-
xdg.mime.defaultApplications."application/pdf" = "ghaf-pdf-xdg.desktop";
78-
xdg.mime.defaultApplications."image/jpeg" = "ghaf-image-xdg.desktop";
79-
xdg.mime.defaultApplications."image/png" = "ghaf-image-xdg.desktop";
77+
xdg.mime.defaultApplications = {
78+
"application/pdf" = "ghaf-pdf-xdg.desktop";
79+
"image/jpeg" = "ghaf-image-xdg.desktop";
80+
"image/png" = "ghaf-image-xdg.desktop";
81+
};
8082
};
8183
}

modules/common/users/desktop.nix

Lines changed: 141 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -149,155 +149,160 @@ in
149149

150150
# Enable homed service
151151
services.homed.enable = true;
152-
systemd.services.systemd-homed.serviceConfig.Restart = "on-failure";
153152

154-
# First boot login user setup service
155-
systemd.services.setup-ghaf-user =
156-
let
157-
userSetupScript = pkgs.writeShellApplication {
158-
name = "setup-ghaf-user";
159-
runtimeInputs = [
160-
pkgs.coreutils
161-
pkgs.ncurses
162-
pkgs.brightnessctl
163-
];
164-
text = ''
165-
brightnessctl set 100%
166-
clear
167-
echo -e "\e[1;32;1mWelcome to Ghaf \e[0m"
168-
echo ""
169-
echo "Start by creating your user account."
170-
echo ""
153+
systemd = {
154+
services = {
155+
systemd-homed.serviceConfig.Restart = "on-failure";
171156

172-
# Read new user name
173-
ACCEPTABLE_USER=false
174-
until $ACCEPTABLE_USER; do
175-
echo -n "Enter your user name: "
176-
read -e -r USERNAME
177-
USERNAME=''${USERNAME// /_}
178-
USERNAME=''${USERNAME//[^a-zA-Z0-9_-]/}
179-
USERNAME=''$(echo -n "$USERNAME" | tr '[:upper:]' '[:lower:]')
180-
if grep -q "$USERNAME:" /etc/passwd; then
181-
echo "User $USERNAME already exists. Please choose another user name."
182-
else
183-
ACCEPTABLE_USER=true
184-
fi
185-
done
157+
# First boot login user setup service
158+
setup-ghaf-user =
159+
let
160+
userSetupScript = pkgs.writeShellApplication {
161+
name = "setup-ghaf-user";
162+
runtimeInputs = [
163+
pkgs.coreutils
164+
pkgs.ncurses
165+
pkgs.brightnessctl
166+
];
167+
text = ''
168+
brightnessctl set 100%
169+
clear
170+
echo -e "\e[1;32;1mWelcome to Ghaf \e[0m"
171+
echo ""
172+
echo "Start by creating your user account."
173+
echo ""
186174
187-
echo ""
188-
echo -n "Enter your full name: "
189-
read -e -r REALNAME
190-
REALNAME=''${REALNAME//[^a-zA-Z ]/}
191-
[[ -n "$REALNAME" ]] || REALNAME="$USERNAME";
175+
# Read new user name
176+
ACCEPTABLE_USER=false
177+
until $ACCEPTABLE_USER; do
178+
echo -n "Enter your user name: "
179+
read -e -r USERNAME
180+
USERNAME=''${USERNAME// /_}
181+
USERNAME=''${USERNAME//[^a-zA-Z0-9_-]/}
182+
USERNAME=''$(echo -n "$USERNAME" | tr '[:upper:]' '[:lower:]')
183+
if grep -q "$USERNAME:" /etc/passwd; then
184+
echo "User $USERNAME already exists. Please choose another user name."
185+
else
186+
ACCEPTABLE_USER=true
187+
fi
188+
done
192189
193-
echo ""
194-
echo "Setting up your user account and creating encrypted home folder after you enter your password."
195-
echo "This may take a while..."
196-
echo ""
190+
echo ""
191+
echo -n "Enter your full name: "
192+
read -e -r REALNAME
193+
REALNAME=''${REALNAME//[^a-zA-Z ]/}
194+
[[ -n "$REALNAME" ]] || REALNAME="$USERNAME";
197195
198-
# Add login user and home
199-
homectl create "$USERNAME" \
200-
--real-name="$REALNAME" \
201-
--skel=/etc/skel \
202-
--storage=luks \
203-
--luks-pbkdf-type=argon2id \
204-
--enforce-password-policy=true \
205-
--drop-caches=true \
206-
--nosuid=true \
207-
--noexec=true \
208-
--nodev=true \
209-
--disk-size=${toString cfg.loginUser.homeSize}M \
210-
--shell=/run/current-system/sw/bin/bash \
211-
--uid=${toString cfg.loginUser.uid} \
212-
--member-of=users${
213-
optionalString (
214-
cfg.loginUser.extraGroups != [ ]
215-
) ",${concatStringsSep "," cfg.loginUser.extraGroups}"
216-
}
196+
echo ""
197+
echo "Setting up your user account and creating encrypted home folder after you enter your password."
198+
echo "This may take a while..."
199+
echo ""
217200
218-
# Lock user creation script
219-
install -m 000 /dev/null /var/lib/nixos/user.lock
201+
# Add login user and home
202+
homectl create "$USERNAME" \
203+
--real-name="$REALNAME" \
204+
--skel=/etc/skel \
205+
--storage=luks \
206+
--luks-pbkdf-type=argon2id \
207+
--enforce-password-policy=true \
208+
--drop-caches=true \
209+
--nosuid=true \
210+
--noexec=true \
211+
--nodev=true \
212+
--disk-size=${toString cfg.loginUser.homeSize}M \
213+
--shell=/run/current-system/sw/bin/bash \
214+
--uid=${toString cfg.loginUser.uid} \
215+
--member-of=users${
216+
optionalString (
217+
cfg.loginUser.extraGroups != [ ]
218+
) ",${concatStringsSep "," cfg.loginUser.extraGroups}"
219+
}
220220
221-
echo ""
222-
echo "User $USERNAME created. Starting user session..."
223-
sleep 1
224-
'';
225-
};
226-
in
227-
{
228-
description = "First boot user setup";
229-
enable = true;
230-
requiredBy = [ "multi-user.target" ];
231-
before = [ "greetd.service" ];
232-
path = [ userSetupScript ];
233-
unitConfig.ConditionPathExists = "!/var/lib/nixos/user.lock";
234-
serviceConfig = {
235-
Type = "oneshot";
236-
StandardInput = "tty";
237-
StandardOutput = "tty";
238-
StandardError = "journal";
239-
TTYPath = "/dev/tty1";
240-
TTYReset = true;
241-
TTYVHangup = true;
242-
ExecStart = "${userSetupScript}/bin/setup-ghaf-user";
243-
};
244-
};
221+
# Lock user creation script
222+
install -m 000 /dev/null /var/lib/nixos/user.lock
223+
224+
echo ""
225+
echo "User $USERNAME created. Starting user session..."
226+
sleep 1
227+
'';
228+
};
229+
in
230+
{
231+
description = "First boot user setup";
232+
enable = true;
233+
requiredBy = [ "multi-user.target" ];
234+
before = [ "greetd.service" ];
235+
path = [ userSetupScript ];
236+
unitConfig.ConditionPathExists = "!/var/lib/nixos/user.lock";
237+
serviceConfig = {
238+
Type = "oneshot";
239+
StandardInput = "tty";
240+
StandardOutput = "tty";
241+
StandardError = "journal";
242+
TTYPath = "/dev/tty1";
243+
TTYReset = true;
244+
TTYVHangup = true;
245+
ExecStart = "${userSetupScript}/bin/setup-ghaf-user";
246+
};
247+
};
245248

246-
systemd.services.setup-test-user =
247-
let
248-
automatedUserSetupScript = pkgs.writeShellApplication {
249-
name = "setup-test-user";
250-
runtimeInputs = [
251-
pkgs.coreutils
252-
];
253-
text = ''
254-
echo "Automated boot user setup script"
249+
setup-test-user =
250+
let
251+
automatedUserSetupScript = pkgs.writeShellApplication {
252+
name = "setup-test-user";
253+
runtimeInputs = [
254+
pkgs.coreutils
255+
];
256+
text = ''
257+
echo "Automated boot user setup script"
255258
256-
# Hardcoded user name
257-
USERNAME="testuser"
258-
REALNAME="Test User"
259-
export PASSWORD="testpw"
260-
export NEWPASSWORD="testpw"
259+
# Hardcoded user name
260+
USERNAME="testuser"
261+
REALNAME="Test User"
262+
export PASSWORD="testpw"
263+
export NEWPASSWORD="testpw"
261264
262-
# Add login user and home
263-
homectl create "$USERNAME" \
264-
--real-name="$REALNAME" \
265-
--skel=/etc/skel \
266-
--storage=luks \
267-
--luks-pbkdf-type=argon2id \
268-
--enforce-password-policy=true \
269-
--drop-caches=true \
270-
--nosuid=true \
271-
--noexec=true \
272-
--nodev=true \
273-
--disk-size=${toString cfg.loginUser.homeSize}M \
274-
--shell=/run/current-system/sw/bin/bash \
275-
--uid=${toString cfg.loginUser.uid} \
276-
--member-of=users${
277-
optionalString (
278-
cfg.loginUser.extraGroups != [ ]
279-
) ",${concatStringsSep "," cfg.loginUser.extraGroups}"
280-
}
265+
# Add login user and home
266+
homectl create "$USERNAME" \
267+
--real-name="$REALNAME" \
268+
--skel=/etc/skel \
269+
--storage=luks \
270+
--luks-pbkdf-type=argon2id \
271+
--enforce-password-policy=true \
272+
--drop-caches=true \
273+
--nosuid=true \
274+
--noexec=true \
275+
--nodev=true \
276+
--disk-size=${toString cfg.loginUser.homeSize}M \
277+
--shell=/run/current-system/sw/bin/bash \
278+
--uid=${toString cfg.loginUser.uid} \
279+
--member-of=users${
280+
optionalString (
281+
cfg.loginUser.extraGroups != [ ]
282+
) ",${concatStringsSep "," cfg.loginUser.extraGroups}"
283+
}
281284
282-
# Lock user creation script
283-
install -m 000 /dev/null /var/lib/nixos/user.lock
284-
echo "User $USERNAME created."
285+
# Lock user creation script
286+
install -m 000 /dev/null /var/lib/nixos/user.lock
287+
echo "User $USERNAME created."
285288
286-
# Stop interactive user setup service
287-
systemctl stop setup-ghaf-user
288-
'';
289-
};
290-
in
291-
mkIf config.ghaf.profiles.debug.enable {
292-
description = "Automated boot user setup script";
293-
enable = true;
294-
path = [ automatedUserSetupScript ];
295-
unitConfig.ConditionPathExists = "!/var/lib/nixos/user.lock";
296-
serviceConfig = {
297-
Type = "oneshot";
298-
ExecStart = "${automatedUserSetupScript}/bin/setup-test-user";
299-
};
289+
# Stop interactive user setup service
290+
systemctl stop setup-ghaf-user
291+
'';
292+
};
293+
in
294+
mkIf config.ghaf.profiles.debug.enable {
295+
description = "Automated boot user setup script";
296+
enable = true;
297+
path = [ automatedUserSetupScript ];
298+
unitConfig.ConditionPathExists = "!/var/lib/nixos/user.lock";
299+
serviceConfig = {
300+
Type = "oneshot";
301+
ExecStart = "${automatedUserSetupScript}/bin/setup-test-user";
302+
};
303+
};
300304
};
305+
};
301306
})
302307
];
303308
}

modules/microvm/virtualization/microvm/appvm.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ in
258258
types.submodule (
259259
{ config, lib, ... }:
260260
{
261-
options = rec {
261+
options = {
262262
name = mkOption {
263263
type = types.str;
264264
description = "The name of the application";

modules/microvm/virtualization/microvm/common/ghaf-audio.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ in
4444

4545
environment = lib.mkIf (!cfg.useTunneling) {
4646
systemPackages = [ pkgs.pulseaudio ];
47-
sessionVariables = rec {
47+
sessionVariables = {
4848
PULSE_SERVER = "${address}";
4949
};
5050
};

0 commit comments

Comments
 (0)