summary refs log tree commit diff
path: root/nix/testVm
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-03-28 14:48:17 +0100
committerRory& <root@rory.gay>2026-03-28 14:48:17 +0100
commit3b74f1377c14cdac99dfeb1b45513c6c31ef378e (patch)
tree72176aa3a4a506bab4d16faebadc7c087ce84142 /nix/testVm
parentAdd indexes to instance bans table (diff)
downloadserver-ts-tmp-musl-fun.tar.xz
Attempt to switch test vm to musl? github/tmp-musl-fun tmp-musl-fun
Diffstat (limited to 'nix/testVm')
-rw-r--r--nix/testVm/configuration.nix38
-rw-r--r--nix/testVm/default.nix1
-rw-r--r--nix/testVm/musl.nix77
-rw-r--r--nix/testVm/perlless.nix26
-rw-r--r--nix/testVm/vm.nix67
5 files changed, 158 insertions, 51 deletions
diff --git a/nix/testVm/configuration.nix b/nix/testVm/configuration.nix

index 1e70da99..ad862a01 100644 --- a/nix/testVm/configuration.nix +++ b/nix/testVm/configuration.nix
@@ -58,6 +58,7 @@ in }; }; + cs.defaultAppsettings.ConnectionStrings.Spacebar = csConnectionString; offload = { enable = true; gateway = { @@ -68,23 +69,11 @@ in enableChannelStatuses = true; enableChannelInfo = true; }; - extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; }; - adminApi = { - enable = true; - extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; - }; - - cdnCs = { - enable = false; - extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; - }; - - uApi = { - enable = true; - extraConfiguration.ConnectionStrings.Spacebar = csConnectionString; - }; + adminApi.enable = true; + cdnCs.enable = false; + uApi.enable = true; pion-sfu = { enable = true; @@ -105,14 +94,17 @@ in }; in lib.trace ("Testing with config: " + builtins.toJSON cfg) cfg; - services.nginx.enable = true; - services.nginx.recommendedOptimisation = true; - services.nginx.appendConfig = '' - worker_processes 6; - ''; - services.nginx.eventsConfig = '' - worker_connections 512; - ''; + + services.nginx = { + enable = true; + recommendedOptimisation = true; + appendConfig = '' + worker_processes 6; + ''; + eventsConfig = '' + worker_connections 512; + ''; + }; users.users.root.initialPassword = "root"; services.getty.autologinUser = "root"; diff --git a/nix/testVm/default.nix b/nix/testVm/default.nix
index 3b67f492..cdacc3da 100644 --- a/nix/testVm/default.nix +++ b/nix/testVm/default.nix
@@ -6,7 +6,6 @@ nixpkgs.lib.nixosSystem { self.nixosModules.default ./configuration.nix ./postgres.nix - ./perlless.nix ./vm.nix ]; specialArgs = { inherit self nixpkgs; }; diff --git a/nix/testVm/musl.nix b/nix/testVm/musl.nix new file mode 100644
index 00000000..0a272c95 --- /dev/null +++ b/nix/testVm/musl.nix
@@ -0,0 +1,77 @@ +# https://github.com/MatthewCroughan/nixos-musl/blob/master/musl.nix +{ pkgs, lib, ... }: +let + glibcPkgs = (import pkgs.path { system = pkgs.stdenv.hostPlatform.system; }); +in +{ + # Fails to build, and doesn't make sense on musl anyway + services.nscd.enableNsncd = false; + services.nscd.enable = false; + system.nssModules = lib.mkForce []; + + # wrappers use pkgsStatic which has issues on native musl at this time + security.enableWrappers = pkgs.stdenv.buildPlatform.isGnu; + + xdg.mime.enable = if (pkgs.stdenv.buildPlatform != pkgs.stdenv.hostPlatform) then false else true; + + # stub-ld doesn't make sense with musl + environment.stub-ld.enable = false; + + # Fails unless neutered error: expected a set but found null: null + i18n.glibcLocales = pkgs.runCommand "neutered" { } "mkdir -p $out"; + + # Perl stuff just fails too hard these days + # services.userborn.enable = true; + + nixpkgs.overlays = [ + (self: super: { + # qemu doesn't build for musl, and if we want to run the + # config.system.build.vm, we need a glibc qemu, doens't impact anything + # else + qemu = glibcPkgs.qemu; + + ## But the qemu_test binary is fine on musl + qemu_test = glibcPkgs.qemu_test; + + # Tests are so flaky... + git = super.git.overrideAttrs { doInstallCheck = false; }; + + # https://github.com/NixOS/nixpkgs/pull/451147 + diffutils = super.diffutils.overrideAttrs (old: { + postPatch = + if (super.stdenv.buildPlatform.isGnu && super.stdenv.hostPlatform.isMusl) then + '' + sed -i -E 's:test-getopt-gnu::g' gnulib-tests/Makefile.in + sed -i -E 's:test-getopt-posix::g' gnulib-tests/Makefile.in + '' else null; + }); + + # checks fail on musl + logrotate = super.logrotate.overrideAttrs { + doCheck = false; + }; + rsync = super.rsync.overrideAttrs { + doCheck = false; + }; + spdlog = super.spdlog.overrideAttrs { + doCheck = false; + }; + }) + ]; + + # These options sometimes work, and sometimes don't, because of perl + nix.enable = lib.mkForce false; + system = { + tools.nixos-generate-config.enable = lib.mkForce false; + switch.enable = lib.mkForce false; + disableInstallerTools = lib.mkForce false; + tools.nixos-option.enable = lib.mkForce false; + }; + documentation = { + enable = false; + doc.enable = false; + info.enable = false; + man.enable = false; + nixos.enable = false; + }; +} \ No newline at end of file diff --git a/nix/testVm/perlless.nix b/nix/testVm/perlless.nix deleted file mode 100644
index 669be83c..00000000 --- a/nix/testVm/perlless.nix +++ /dev/null
@@ -1,26 +0,0 @@ -{ lib, ... }: -{ - #perlless profile - #system.switch.enable = lib.mkForce false; - - # Remove perl from activation - #system.etc.overlay.enable = lib.mkForce true; - #systemd.sysusers.enable = lib.mkForce true; - - # Random perl remnants - programs.less.lessopen = lib.mkForce null; - programs.command-not-found.enable = lib.mkForce false; - environment.defaultPackages = lib.mkForce [ ]; - documentation.info.enable = lib.mkForce false; - documentation.man.enable = false; - - system = { - #activatable = false; - copySystemConfiguration = false; - includeBuildDependencies = false; - disableInstallerTools = lib.mkForce true; - build = { - separateActivationScript = true; - }; - }; -} diff --git a/nix/testVm/vm.nix b/nix/testVm/vm.nix
index 0c61aa83..3f2e9311 100644 --- a/nix/testVm/vm.nix +++ b/nix/testVm/vm.nix
@@ -1,4 +1,5 @@ { + config, pkgs, lib, modulesPath, @@ -6,7 +7,8 @@ }: { imports = [ -# (modulesPath + "/virtualisation/qemu-vm.nix") + # (modulesPath + "/virtualisation/qemu-vm.nix") + ./musl.nix ]; virtualisation.vmVariant = { @@ -59,4 +61,67 @@ font = "${pkgs.cozette}/share/consolefonts/cozette6x13.psfu"; packages = with pkgs; [ cozette ]; }; + + # Remove perl from activation + system.etc.overlay.enable = lib.mkForce true; + systemd.sysusers.enable = lib.mkForce true; + + programs.less.lessopen = lib.mkForce null; + programs.command-not-found.enable = lib.mkForce false; + environment.defaultPackages = lib.mkForce [ ]; + documentation.info.enable = lib.mkForce false; + documentation.man.enable = false; + + system = { + copySystemConfiguration = false; + includeBuildDependencies = false; + disableInstallerTools = lib.mkForce true; + build = { + separateActivationScript = true; + }; + switch.enable = lib.mkForce false; + nixos-init.enable = true; + }; + + nixpkgs.hostPlatform = { + system = "x86_64-linux"; + config = "x86_64-unknown-linux-musl"; + }; + + boot.loader.grub.enable = lib.mkDefault false; + fileSystems."/".device = lib.mkDefault "/dev/disk/by-label/nixos"; + # https://github.com/NixOS/nixpkgs/pull/496852/changes + boot.postBootCommands = lib.mkForce ""; + systemd.services.register-nix-paths = lib.mkIf config.nix.enable { + # Run early during boot so the nix store DB is populated before any + # service (or test backdoor) tries to use nix commands. + # nix-store --load-db writes to the SQLite DB directly, so it does not + # need the nix-daemon. + unitConfig.DefaultDependencies = false; + wantedBy = [ + "sysinit.target" + ]; + before = [ + "sysinit.target" + "shutdown.target" + "nix-daemon.socket" + "nix-daemon.service" + ]; + after = [ + "local-fs.target" + ]; + conflicts = [ + "shutdown.target" + ]; + restartIfChanged = false; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + if [[ "$(cat /proc/cmdline)" =~ regInfo=([^ ]*) ]]; then + ${lib.getExe' config.nix.package.out "nix-store"} --load-db < "''${BASH_REMATCH[1]}" + fi + ''; + }; }