aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sandbox/configuration.nix
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-30 22:03:48 +0900
committerOphestra <cat@gensokyo.uk>2025-03-30 22:09:46 +0900
commit297b444dfb6adb71d5d1e61ea1b5aff16683896e (patch)
tree61136bffe95aae67baa436b20ce60b7b9074d126 /test/sandbox/configuration.nix
parent89a05909a4fb393864a8aa752f6979dd9aaa2898 (diff)
test: separate app and sandbox
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/sandbox/configuration.nix')
-rw-r--r--test/sandbox/configuration.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/sandbox/configuration.nix b/test/sandbox/configuration.nix
new file mode 100644
index 00000000..5bca7fed
--- /dev/null
+++ b/test/sandbox/configuration.nix
@@ -0,0 +1,76 @@
+{
+ lib,
+ pkgs,
+ config,
+ ...
+}:
+let
+ testProgram = pkgs.callPackage ./tool/package.nix { inherit (config.environment.fortify.package) version; };
+ testCases = import ./case lib testProgram;
+in
+{
+ users.users = {
+ alice = {
+ isNormalUser = true;
+ description = "Alice Foobar";
+ password = "foobar";
+ uid = 1000;
+ };
+ };
+
+ home-manager.users.alice.home.stateVersion = "24.11";
+
+ # Automatically login on tty1 as a normal user:
+ services.getty.autologinUser = "alice";
+
+ environment = {
+ systemPackages = with pkgs; [
+ # For checking seccomp outcome:
+ testProgram
+ ];
+
+ variables = {
+ SWAYSOCK = "/tmp/sway-ipc.sock";
+ WLR_RENDERER = "pixman";
+ };
+ };
+
+ # Automatically configure and start Sway when logging in on tty1:
+ programs.bash.loginShellInit = ''
+ if [ "$(tty)" = "/dev/tty1" ]; then
+ set -e
+
+ mkdir -p ~/.config/sway
+ (sed s/Mod4/Mod1/ /etc/sway/config &&
+ echo 'output * bg ${pkgs.nixos-artwork.wallpapers.simple-light-gray.gnomeFilePath} fill' &&
+ echo 'output Virtual-1 res 1680x1050') > ~/.config/sway/config
+
+ sway --validate
+ systemd-cat --identifier=session sway && touch /tmp/sway-exit-ok
+ fi
+ '';
+
+ programs.sway.enable = true;
+
+ virtualisation.qemu.options = [
+ # Need to switch to a different GPU driver than the default one (-vga std) so that Sway can launch:
+ "-vga none -device virtio-gpu-pci"
+
+ # Increase performance:
+ "-smp 8"
+ ];
+
+ environment.fortify = {
+ enable = true;
+ stateDir = "/var/lib/fortify";
+ users.alice = 0;
+
+ home-manager = _: _: { home.stateVersion = "23.05"; };
+
+ apps = [
+ testCases.preset
+ testCases.tty
+ testCases.mapuid
+ ];
+ };
+}