Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ghaf user accounts #827

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
};

impermanence = {
url = "github:nix-community/impermanence";
url = "github:nix-community/impermanence/32b1094d28d5fbedcc85a403bc08c8877b396255";
};

givc = {
Expand Down
2 changes: 1 addition & 1 deletion modules/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
./firewall
./profiles
./security
./users/accounts.nix
./users
./version
./virtualization/docker.nix
./systemd
Expand Down
1 change: 0 additions & 1 deletion modules/common/profiles/debug.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ in
config = lib.mkIf cfg.enable {
# Enable default accounts and passwords
ghaf = {
users.accounts.enable = true;
# Enable development on target
development = {
nix-setup.enable = true;
Expand Down
2 changes: 1 addition & 1 deletion modules/common/profiles/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ in
# TODO this needs to be refined when we define a policy for the
# processes and the UID/groups that should be enabled by default
# if not already covered by systemd
ghaf.users.accounts.enable = true;
# ghaf.users.admin.enable = true;
};
}
7 changes: 0 additions & 7 deletions modules/common/services/audio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ in
};
};

# Allow ghaf user to access pulseaudio and pipewire
users.extraUsers.ghaf.extraGroups = [
"audio"
"video"
"pipewire"
];

# Start pipewire on system boot
systemd.services.pipewire.wantedBy = [ "multi-user.target" ];

Expand Down
23 changes: 2 additions & 21 deletions modules/common/services/fprint.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,19 @@ in
// Allow user to verify fingerprints
polkit.addRule(function(action, subject) {
if (action.id == "net.reactivated.fprint.device.verify" &&
subject.user == "ghaf") {
subject.isInGroup ("users")) {
return polkit.Result.YES;
}
});
// Allow user to enroll fingerprints
polkit.addRule(function(action, subject) {
if (action.id == "net.reactivated.fprint.device.enroll" &&
subject.user == "ghaf") {
subject.isInGroup ("users")) {
return polkit.Result.YES;
}
});
'';
};
# PAM rules for swaylock fingerprint reader
pam.services = {
swaylock.text = ''
# Account management.
account required pam_unix.so

# Authentication management.
auth sufficient pam_unix.so likeauth try_first_pass
auth sufficient ${pkgs.fprintd}/lib/security/pam_fprintd.so
auth required pam_deny.so

# Password management.
password sufficient pam_unix.so nullok sha512

# Session management.
session required pam_env.so conffile=/etc/pam/environment readenv=0
session required pam_unix.so
'';
};
};
};
}
4 changes: 1 addition & 3 deletions modules/common/services/xdgopener.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let
# into all targets
ghaf-xdg-open = pkgs.callPackage ../../../packages/ghaf-xdg-open {
inherit (config.ghaf.security.sshKeys) sshKeyPath;
user = config.ghaf.users.appUser.name;
};
in
{
Expand Down Expand Up @@ -51,9 +52,6 @@ in
services."xdg@" = {
description = "XDG opener";
serviceConfig = {
# The user 'ghaf' is used here to access SSH keys for the scp command
# This is required to copy files to the zathuravm
User = "ghaf";
ExecStart = "${ghaf-xdg-open}/bin/ghaf-xdg-open";
StandardInput = "socket";
StandardOutput = "journal";
Expand Down
38 changes: 37 additions & 1 deletion modules/common/systemd/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let
mkIf
mkForce
types
optionalAttrs
;

# Override minimal systemd package configuration
Expand All @@ -29,10 +30,11 @@ let
inherit (cfg) withAudit;
withCompression = true;
withCoredump = cfg.withDebug || cfg.withMachines;
inherit (cfg) withCryptsetup;
withCryptsetup = cfg.withCryptsetup || cfg.withHomed;
inherit (cfg) withEfi;
inherit (cfg) withBootloader;
inherit (cfg) withFido2;
inherit (cfg) withHomed;
inherit (cfg) withHostnamed;
withImportd = cfg.withMachines;
withKexectools = cfg.withDebug;
Expand All @@ -54,6 +56,7 @@ let
inherit (cfg) withTimesyncd;
inherit (cfg) withTpm2Tss;
inherit (cfg) withUkify;
withUserDb = cfg.withHomed;
withUtmp = cfg.withJournal || cfg.withAudit;
}
// lib.optionalAttrs (lib.strings.versionAtLeast pkgs.systemdMinimal.version "255.0") {
Expand Down Expand Up @@ -150,6 +153,12 @@ let
"systemd-networkd.service"
"systemd-networkd.socket"
])
++ (lib.optionals (!cfg.withAudio) [
"sound.target"
])
++ (lib.optionals (!cfg.withBluetooth) [
"bluetooth.target"
])
++ (lib.optionals (!cfg.withDebug) [
## Units kept with debug
"kbrequest.target"
Expand Down Expand Up @@ -223,6 +232,12 @@ in
default = false;
};

withHomed = mkOption {
description = "Enable systemd homed for users home functionality.";
type = types.bool;
default = false;
};

withHostnamed = mkOption {
description = "Enable systemd hostname daemon.";
type = types.bool;
Expand Down Expand Up @@ -307,11 +322,29 @@ in
default = false;
};

withAudio = mkOption {
description = "Enable audio functionality.";
type = types.bool;
default = false;
};

withBluetooth = mkOption {
description = "Enable bluetooth functionality.";
type = types.bool;
default = false;
};

withDebug = mkOption {
description = "Enable systemd debug functionality.";
type = types.bool;
default = false;
};

verboseLogs = mkOption {
description = "Increase systemd log verbosity.";
type = types.bool;
default = false;
};
};

config = mkIf cfg.enable {
Expand All @@ -324,6 +357,9 @@ in
# Misc. configurations
enableEmergencyMode = cfg.withDebug;
coredump.enable = cfg.withDebug || cfg.withMachines;
managerEnvironment = optionalAttrs cfg.verboseLogs {
SYSTEMD_LOG_LEVEL = "debug";
};

# Service startup optimization
services.systemd-networkd-wait-online.enable = mkForce false;
Expand Down
24 changes: 17 additions & 7 deletions modules/common/systemd/boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ let
cfg = config.ghaf.systemd.boot;
cfgBase = config.ghaf.systemd;

inherit (lib) mkEnableOption mkIf optionals;
inherit (lib)
mkIf
optionals
mkOption
optionalAttrs
;

# Package configuration
package = pkgs.systemdMinimal.override (
Expand All @@ -33,8 +38,7 @@ let

# Suppressed initrd systemd units
suppressedUnits =
[ "multi-user.target" ]
++ (lib.optionals ((!cfgBase.withDebug) && (!cfgBase.withJournal)) [
(lib.optionals ((!cfgBase.withDebug) && (!cfgBase.withJournal)) [
"systemd-journald.service"
"systemd-journald.socket"
"systemd-journald-dev-log.socket"
Expand All @@ -54,23 +58,29 @@ let
in
{
options.ghaf.systemd.boot = {
enable = mkEnableOption "Enable systemd in stage 1 of the boot (initrd).";
enable = mkOption {
default = config.ghaf.systemd.enable;
description = "Enable systemd in stage 1 of the boot (initrd).";
};
};

config = mkIf cfg.enable {
boot.initrd = {
verbose = config.ghaf.profiles.debug.enable;
verbose = cfgBase.verboseLogs;
services.lvm.enable = true;
systemd = {
enable = true;
inherit package;
inherit suppressedUnits;
emergencyAccess = config.ghaf.profiles.debug.enable;
emergencyAccess = cfgBase.withDebug;
tpm2.enable = cfgBase.withTpm2Tss;
initrdBin = optionals config.ghaf.profiles.debug.enable [
initrdBin = optionals cfgBase.withDebug [
pkgs.lvm2
pkgs.util-linux
];
managerEnvironment = optionalAttrs cfgBase.verboseLogs {
SYSTEMD_LOG_LEVEL = "debug";
};
};
};
};
Expand Down
66 changes: 0 additions & 66 deletions modules/common/users/accounts.nix

This file was deleted.

Loading
Loading