summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-04-10 21:46:54 +0000
committerAlyssa Ross <hi@alyssa.is>2021-04-14 23:38:56 +0000
commitc643e387ff1f048779b4c73bba60dae3bda84921 (patch)
tree9f7fb21ce447cc49f6214e43e38d16adcd985782
parente73506be2a29a29c6507285393aec81181061cb1 (diff)
downloadnixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.tar
nixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.tar.gz
nixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.tar.bz2
nixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.tar.lz
nixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.tar.xz
nixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.tar.zst
nixpkgs-c643e387ff1f048779b4c73bba60dae3bda84921.zip
spectrumPackages.sys-vms.comp: init
This removes the default rootfs, and creates a VM called "comp" that
runs all the Wayfire stuff the default rootfs did previously.

This is in a new namespace called sys-vms, which I have a very vague
intention of being a place to put VMs that run system services like a
Wayland compositor or hardware drivers.  I don't think this will be
the final structure, but it's _a_ structure that supports more than
one VM, so it's an improvement over what we had before.

Message-Id: <20210411115740.29615-13-hi@alyssa.is>
Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>
-rw-r--r--pkgs/os-specific/linux/spectrum/default.nix4
-rw-r--r--pkgs/os-specific/linux/spectrum/rootfs/default.nix78
-rw-r--r--pkgs/os-specific/linux/spectrum/spectrum-vm/default.nix6
-rw-r--r--pkgs/os-specific/linux/spectrum/vm/comp/default.nix86
-rw-r--r--pkgs/os-specific/linux/spectrum/vm/default.nix5
5 files changed, 96 insertions, 83 deletions
diff --git a/pkgs/os-specific/linux/spectrum/default.nix b/pkgs/os-specific/linux/spectrum/default.nix
index ea86dc25c2b..f8a9813d16a 100644
--- a/pkgs/os-specific/linux/spectrum/default.nix
+++ b/pkgs/os-specific/linux/spectrum/default.nix
@@ -4,13 +4,13 @@ let
   self = with self; {
     callPackage = newScope self;
 
+    sys-vms = callPackage ./vm { };
+
     spectrum-vm = callPackage ./spectrum-vm { linux = linux_vm; };
 
     linux_vm = callPackage ./linux/vm.nix { linux = linux_cros; };
 
     makeRootfs = callPackage ./rootfs/generic.nix { };
-
-    rootfs = callPackage ./rootfs { };
   };
 in
 self
diff --git a/pkgs/os-specific/linux/spectrum/rootfs/default.nix b/pkgs/os-specific/linux/spectrum/rootfs/default.nix
deleted file mode 100644
index 70ddac4c545..00000000000
--- a/pkgs/os-specific/linux/spectrum/rootfs/default.nix
+++ /dev/null
@@ -1,78 +0,0 @@
-{ writeScript, writeText, lib, makeRootfs
-, busybox, execline, s6, sommelier, source-code-pro, wayfire, zsh
-, gcc, emacs26-nox, westonLite
-}:
-
-let
-  path = [
-    zsh emacs26-nox gcc wayfire sommelier westonLite busybox s6 execline
-  ];
-
-  login = writeScript "login" ''
-    #! ${execline}/bin/execlineb -s0
-    unexport !
-    ${busybox}/bin/login -p -f root $@
-  '';
-
-  # This can't be /etc/wayfire/defaults.ini because autostart entries
-  # from that file aren't applied.
-  wayfireConfig = writeText "wayfire-config" ''
-    [core]
-    xwayland = false
-
-    [input]
-    xkb_layout = us
-    xkb_variant = dvorak
-
-    [autostart]
-    terminal = weston-terminal --shell $(command -v zsh)
-  '';
-in
-
-makeRootfs {
-  services.getty.run = writeScript "getty-run" ''
-    #! ${execline}/bin/execlineb -P
-    ${busybox}/bin/getty -i -n -l ${login} 38400 ttyS0
-  '';
-
-  rcServices.ok-all = {
-    type = writeText "ok-all-type" ''
-      bundle
-    '';
-    contents = writeText "ok-all-contents" ''
-      wayfire
-    '';
-  };
-
-  rcServices.wayfire = {
-    type = writeText "wayfire-type" ''
-      longrun
-    '';
-    run = writeScript "wayfire-run" ''
-      #! ${execline}/bin/execlineb -S0
-
-      s6-applyuidgid -u 1000 -g 1000
-
-      export HOME /
-      export PATH ${lib.makeBinPath path}
-      export XDG_RUNTIME_DIR /run/user/1000
-
-      ${sommelier}/bin/sommelier
-      wayfire -c ${wayfireConfig}
-    '';
-    dependencies = writeText "wayfire-dependencies" ''
-      wl0
-    '';
-  };
-
-  rcServices.wl0 = {
-    type = writeText "wl0-type" ''
-      oneshot
-    '';
-    up = writeText "wl0-run" ''
-      chown user /dev/wl0
-    '';
-  };
-
-  fonts = [ source-code-pro ];
-}
diff --git a/pkgs/os-specific/linux/spectrum/spectrum-vm/default.nix b/pkgs/os-specific/linux/spectrum/spectrum-vm/default.nix
index 56f1eadea99..c56d2537c63 100644
--- a/pkgs/os-specific/linux/spectrum/spectrum-vm/default.nix
+++ b/pkgs/os-specific/linux/spectrum/spectrum-vm/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, makeWrapper, utillinux, crosvm, linux, rootfs }:
+{ stdenv, lib, makeWrapper, utillinux, crosvm, linux, sys-vms }:
 
 stdenv.mkDerivation {
   name = "spectrum-vm";
@@ -18,8 +18,8 @@ stdenv.mkDerivation {
 
   getopt = "${lib.getBin utillinux}/bin/getopt";
   crosvm = "${lib.getBin crosvm}/bin/crosvm";
-  kernel = "${linux}/bzImage";
-  rootfs = rootfs.squashfs;
+  kernel = "${sys-vms.comp.linux}/bzImage";
+  rootfs = sys-vms.comp.rootfs.squashfs;
 
   installPhase = ''
     mkdir -p $out/bin
diff --git a/pkgs/os-specific/linux/spectrum/vm/comp/default.nix b/pkgs/os-specific/linux/spectrum/vm/comp/default.nix
new file mode 100644
index 00000000000..988fad5fba6
--- /dev/null
+++ b/pkgs/os-specific/linux/spectrum/vm/comp/default.nix
@@ -0,0 +1,86 @@
+{ lib, makeRootfs, runCommand, writeScript, writeText
+, busybox, emacs26-nox, execline, gcc, linux_vm, s6, sommelier, source-code-pro
+, wayfire, westonLite, zsh
+}:
+
+runCommand "vm-comp" rec {
+  linux = linux_vm;
+
+  path = [
+    busybox emacs26-nox execline gcc s6 sommelier wayfire westonLite zsh
+  ];
+
+  login = writeScript "login" ''
+    #! ${execline}/bin/execlineb -s0
+    unexport !
+    ${busybox}/bin/login -p -f root $@
+  '';
+
+  # This can't be /etc/wayfire/defaults.ini because autostart entries
+  # from that file aren't applied.
+  wayfireConfig = writeText "wayfire-config" ''
+    [core]
+    xwayland = false
+
+    [input]
+    xkb_layout = us
+    xkb_variant = dvorak
+
+    [autostart]
+    terminal = weston-terminal --shell $(command -v zsh)
+  '';
+
+  rootfs = makeRootfs {
+    services.getty.run = writeScript "getty-run" ''
+      #! ${execline}/bin/execlineb -P
+      ${busybox}/bin/getty -i -n -l ${login} 38400 ttyS0
+    '';
+
+    rcServices.ok-all = {
+      type = writeText "ok-all-type" ''
+        bundle
+      '';
+      contents = writeText "ok-all-contents" ''
+        wayfire
+      '';
+    };
+
+    rcServices.wayfire = {
+      type = writeText "wayfire-type" ''
+        longrun
+      '';
+      run = writeScript "wayfire-run" ''
+        #! ${execline}/bin/execlineb -S0
+
+        s6-applyuidgid -u 1000 -g 1000
+
+        export HOME /
+        export PATH ${lib.makeBinPath path}
+        export XDG_RUNTIME_DIR /run/user/1000
+
+        ${sommelier}/bin/sommelier
+        wayfire -c ${wayfireConfig}
+      '';
+      dependencies = writeText "wayfire-dependencies" ''
+        wl0
+      '';
+    };
+
+    rcServices.wl0 = {
+      type = writeText "wl0-type" ''
+        oneshot
+      '';
+      up = writeText "wl0-run" ''
+        chown user /dev/wl0
+      '';
+    };
+
+    fonts = [ source-code-pro ];
+  };
+
+  inherit (rootfs) squashfs;
+} ''
+  mkdir $out
+  ln -s $linux/bzImage $out/kernel
+  ln -s $squashfs $out/squashfs
+''
diff --git a/pkgs/os-specific/linux/spectrum/vm/default.nix b/pkgs/os-specific/linux/spectrum/vm/default.nix
new file mode 100644
index 00000000000..582a0c2e9c3
--- /dev/null
+++ b/pkgs/os-specific/linux/spectrum/vm/default.nix
@@ -0,0 +1,5 @@
+{ callPackage }:
+
+{
+  comp = callPackage ./comp { };
+}