patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 00052222507077b9e94a5ed0a3fbddd27caeefc3 5109 bytes (raw)
name: host/rootfs/default.nix 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021-2025 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2022 Unikie

import ../../lib/call-package.nix (
{ callSpectrumPackage, spectrum-build-tools, src
, pkgsMusl, pkgsStatic, linux_latest, systemd
}:
pkgsStatic.callPackage (

{ busybox, cloud-hypervisor, cryptsetup, dbus, erofs-utils, execline
, inkscape, inotify-tools, iproute2, jq, lib, mdevd, nixos
, runCommand, s6, s6-linux-init, s6-rc, socat, spectrum-host-tools
, stdenvNoCC, util-linux, virtiofsd, writeClosure
, xdg-desktop-portal-spectrum-host, xorg
}:
let
  inherit (lib)
    concatMapStringsSep concatStrings escapeShellArg
    escapeShellArgs fileset mapAttrsToList systems trivial;
  pkgsGui = pkgsMusl.extend (
    _final: super:
    (lib.optionalAttrs (systems.equals pkgsMusl.stdenv.hostPlatform super.stdenv.hostPlatform) {
      malcontent = super.malcontent.overrideAttrs ({ meta ? { }, ... }: {
        meta = meta // {
          platforms = [ ];
        };
      });
   }));
in
# Something already pulls in the full
# systemd, so might as well use it.
pkgsGui.callPackage (
{ cosmic-files, crosvm, dejavu_fonts, foot, kmod, mesa
, westonLite, xdg-desktop-portal, xdg-desktop-portal-gtk
}:

let
  inherit (nixosAllHardware.config.hardware) firmware;
  no_pgo_foot = foot.override { allowPgo = false; };

  packages = [
    cloud-hypervisor crosvm cryptsetup dbus execline inotify-tools
    iproute2 jq mdevd s6 s6-linux-init s6-rc socat
    spectrum-host-tools virtiofsd xdg-desktop-portal-spectrum-host

    (busybox.override {
      extraConfig = ''
        CONFIG_CHATTR n
        CONFIG_DEPMOD n
        CONFIG_FINDFS n
        CONFIG_HALT n
        CONFIG_INIT n
        CONFIG_INSMOD n
        CONFIG_IP n
        CONFIG_LSATTR n
        CONFIG_LSMOD n
        CONFIG_MKE2FS n
        CONFIG_MKFS_EXT2 n
        CONFIG_MODINFO n
        CONFIG_MODPROBE n
        CONFIG_MOUNT n
        CONFIG_POWEROFF n
        CONFIG_REBOOT n
        CONFIG_RMMOD n
        CONFIG_SHUTDOWN n
      '';
    })
  ];

  nixosAllHardware = nixos ({ modulesPath, ... }: {
    imports = [ (modulesPath + "/profiles/all-hardware.nix") ];

    system.stateVersion = trivial.release;
  });

  kernel = linux_latest;

  appvm = callSpectrumPackage ../../img/app { inherit (no_pgo_foot) terminfo; };
  netvm = callSpectrumPackage ../../vm/sys/net { inherit (no_pgo_foot) terminfo; };

  # Packages that should be fully linked into /usr,
  # (not just their bin/* files).
  usrPackages = [
    appvm kernel.modules firmware kmod kmod.lib
    netvm mesa dejavu_fonts systemd util-linux westonLite
  ];

  appvms = {
    appvm-firefox = callSpectrumPackage ../../vm/app/firefox.nix {};
    appvm-foot = callSpectrumPackage ../../vm/app/foot.nix {};
    appvm-gnome-text-editor = callSpectrumPackage ../../vm/app/gnome-text-editor.nix {};
  };

  packagesSysroot = runCommand "packages-sysroot" {
    depsBuildBuild = [ inkscape ];
    nativeBuildInputs = [ xorg.lndir ];
  } ''
    mkdir -p $out/usr/bin $out/usr/share/dbus-1/services \
      $out/usr/share/icons/hicolor/20x20/apps

    for pkg in ${escapeShellArgs usrPackages}; do
        lndir -ignorelinks -silent "$pkg" "$out/usr"
    done

    # Weston doesn't support SVG icons.
    inkscape -w 20 -h 20 \
        -o $out/usr/share/icons/hicolor/20x20/apps/com.system76.CosmicFiles.png \
        ${cosmic-files}/share/icons/hicolor/24x24/apps/com.system76.CosmicFiles.svg

    ln -sft "$out/usr/bin" \
        ${concatMapStringsSep " " (p: "${escapeShellArg p}/bin/*") packages} \
        ${escapeShellArg xdg-desktop-portal}/libexec/xdg-document-portal \
        ${escapeShellArg xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk
    ln -st $out/usr/share/dbus-1 \
        ${escapeShellArg dbus}/share/dbus-1/session.conf
    ln -st $out/usr/share/dbus-1/services \
        ${escapeShellArg xdg-desktop-portal-gtk}/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service
    # clobber any conflicting files from busybox
    ln -sft "$out/usr/bin" ${escapeShellArg util-linux}/bin/*

    ${concatStrings (mapAttrsToList (name: path: ''
      ln -s ${path} $out/usr/lib/spectrum/vm/${name}
    '') appvms)}
  '';
in

stdenvNoCC.mkDerivation {
  name = "spectrum-rootfs";

  src = fileset.toSource {
    root = ../..;
    fileset = fileset.intersection src (fileset.unions [
      ./.
      ../../lib/common.mk
      ../../scripts/make-erofs.sh
    ]);
  };
  sourceRoot = "source/host/rootfs";

  nativeBuildInputs = [ erofs-utils spectrum-build-tools s6-rc ];

  env = {
    PACKAGES = runCommand "packages" {} ''
      printf "%s\n/\n" ${packagesSysroot} >$out
      sed p ${writeClosure [ packagesSysroot] } >>$out
    '';
  };

  makeFlags = [ "dest=$(out)" ];

  dontInstall = true;

  enableParallelBuilding = true;

  __structuredAttrs = true;
  unsafeDiscardReferences = { out = true; };
  dontFixup = true;

  passthru = {
    inherit appvm firmware kernel nixosAllHardware packagesSysroot;
  };

  meta = with lib; {
    license = licenses.eupl12;
    platforms = platforms.linux;
  };
}
) {}) {}) (_: {})

debug log:

solving 00052222507077b9e94a5ed0a3fbddd27caeefc3 ...
found 00052222507077b9e94a5ed0a3fbddd27caeefc3 in https://inbox.spectrum-os.org/spectrum-devel/20251029-updates-v1-1-401c1be2a11b@gmail.com/
found 0d79f7ca54ccc86eb0fa6e743f2011237d365f24 in https://inbox.spectrum-os.org/spectrum-devel/20251107-udev-v6-2-176246281424@gmail.com/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20251103-udev-v6-2-704649b85d6d@gmail.com/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20251103-udev-v5-2-5c432ef1ddf8@gmail.com/
found 9632f52674521bafb4ca122f15fc30a52abaad18 in https://spectrum-os.org/git/spectrum
preparing index
index prepared:
100644 9632f52674521bafb4ca122f15fc30a52abaad18	host/rootfs/default.nix

applying [1/2] https://inbox.spectrum-os.org/spectrum-devel/20251107-udev-v6-2-176246281424@gmail.com/
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 9632f52674521bafb4ca122f15fc30a52abaad18..0d79f7ca54ccc86eb0fa6e743f2011237d365f24 100644

Checking patch host/rootfs/default.nix...
Applied patch host/rootfs/default.nix cleanly.

skipping https://inbox.spectrum-os.org/spectrum-devel/20251103-udev-v6-2-704649b85d6d@gmail.com/ for 0d79f7ca54ccc86eb0fa6e743f2011237d365f24
skipping https://inbox.spectrum-os.org/spectrum-devel/20251103-udev-v5-2-5c432ef1ddf8@gmail.com/ for 0d79f7ca54ccc86eb0fa6e743f2011237d365f24
index at:
100644 0d79f7ca54ccc86eb0fa6e743f2011237d365f24	host/rootfs/default.nix

applying [2/2] https://inbox.spectrum-os.org/spectrum-devel/20251029-updates-v1-1-401c1be2a11b@gmail.com/
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 0d79f7ca54ccc86eb0fa6e743f2011237d365f24..00052222507077b9e94a5ed0a3fbddd27caeefc3 100644

Checking patch host/rootfs/default.nix...
Applied patch host/rootfs/default.nix cleanly.

index at:
100644 00052222507077b9e94a5ed0a3fbddd27caeefc3	host/rootfs/default.nix

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).