patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob f161c26e8b3cc3a46d3321d88a52c446e2faac96 5385 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
 
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2021-2025 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2022 Unikie

import ../../lib/call-package.nix (
{ callSpectrumPackage, config, spectrum-build-tools
, src, pkgsMusl, inkscape, linuxPackagesFor, linux_latest, xorg
}:
pkgsMusl.callPackage (

{ spectrum-host-tools, spectrum-router, spectrum-cgroup-setup
, lib, stdenvNoCC, nixos, runCommand, writeClosure, erofs-utils, s6-rc
, btrfs-progs, bubblewrap, busybox, cloud-hypervisor, cosmic-files
, crosvm, cryptsetup, dejavu_fonts, dbus, execline, foot, fuse3
, iproute2, inotify-tools, jq, kmod, lvm2, mdevd, mesa, mount-flatpak
, s6, s6-linux-init, shadow, socat, systemd, util-linuxMinimal, virtiofsd
, westonLite, xdg-desktop-portal, xdg-desktop-portal-gtk
, xdg-desktop-portal-spectrum-host
}:

let
  inherit (nixosAllHardware.config.hardware) firmware;
  inherit (lib)
    concatMapStringsSep concatStrings escapeShellArgs fileset mapAttrsToList
    trivial;

  packages = [
    btrfs-progs bubblewrap cloud-hypervisor cosmic-files crosvm cryptsetup dbus
    execline fuse3 inotify-tools iproute2 jq kmod mdevd mount-flatpak s6
    s6-linux-init s6-rc shadow socat spectrum-cgroup-setup spectrum-host-tools
    spectrum-router virtiofsd xdg-desktop-portal-spectrum-host

    (foot.override { allowPgo = false; })

    (busybox.override {
      # Use a separate file as it is a bit too big.
      extraConfig = builtins.readFile ./busybox-config;
    })

    (util-linuxMinimal.overrideAttrs ({ configureFlags ? [], ... }: {
      # Conflicts with shadow.
      configureFlags = configureFlags ++ [ "--disable-nologin" ];
    }))
  ];

  nixosAllHardware = nixos ({ modulesPath, ... }: {
    boot.kernelPackages = linuxPackagesFor kernel;

    hardware.enableAllHardware = true;

    system.stateVersion = trivial.release;
  });

  kernel = linux_latest;

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

  # Packages that should be fully linked into /usr,
  # (not just their bin/* files).
  #
  # kmod.lib is dlopen()ed by systemd-udevd via libsystemd-shared.so.
  # It doesn't get picked up from libsystemd-shared.so's RUNPATH due to
  # https://inbox.vuxu.org/musl/20251017-dlopen-use-rpath-of-caller-dso-v1-1-46c69eda1473@iscas.ac.cn/
  usrPackages = [
    appvm dejavu_fonts firmware kernel.modules kmod.lib lvm2 mesa
    netvm systemd 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 {};
    appvm-systemd-sysupdate = callSpectrumPackage ../../vm/app/systemd-sysupdate {};
  };

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

    # lndir silently ignores existing links, so run it before ln
    # so that ln catches any duplicates.
    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 -st $out/usr/bin \
        ${concatMapStringsSep " " (p: "${p}/bin/*") packages} \
        ${xdg-desktop-portal}/libexec/xdg-document-portal \
        ${xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk
    ln -st $out/usr/share/dbus-1 \
        ${dbus}/share/dbus-1/session.conf
    ln -st $out/usr/share/dbus-1/services \
        ${xdg-desktop-portal-gtk}/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service

    ${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
      ../../lib/targets.mk
      ../../scripts/make-erofs.sh
    ]);
  };
  sourceRoot = "source/host/rootfs";

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

  env = {
    PACKAGES = runCommand "packages" {} ''
      printf "%s\n/\n" ${packagesSysroot} >$out
      sed p ${writeClosure [ packagesSysroot] } >>$out
    '';
    UPDATE_SIGNING_KEY = builtins.path {
      name = "signing-key";
      path = config.updateSigningKey;
    };
    UPDATE_URL = config.updateUrl;
    VERSION = config.version;
  };

  # The Makefile uses $(ROOT_FS), not $(dest), so it can share code
  # with other Makefiles that also use this variable.
  makeFlags = [ "ROOT_FS=$(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 f161c26e8b3cc3a46d3321d88a52c446e2faac96 ...
found f161c26e8b3cc3a46d3321d88a52c446e2faac96 in https://inbox.spectrum-os.org/spectrum-devel/20260711-cgroups-v3-3-5cba61a20cba@gmail.com/
found 4dcc10b9933cdfaf87f87417db1de0daa57b73f5 in https://inbox.spectrum-os.org/spectrum-devel/20260711-cgroups-v3-2-5cba61a20cba@gmail.com/
found 6bfeefbe0a5f76c1538ccb40e5eb8f291f5d3592 in https://spectrum-os.org/git/spectrum
preparing index
index prepared:
100644 6bfeefbe0a5f76c1538ccb40e5eb8f291f5d3592	host/rootfs/default.nix

applying [1/2] https://inbox.spectrum-os.org/spectrum-devel/20260711-cgroups-v3-2-5cba61a20cba@gmail.com/
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 6bfeefbe0a5f76c1538ccb40e5eb8f291f5d3592..4dcc10b9933cdfaf87f87417db1de0daa57b73f5 100644


applying [2/2] https://inbox.spectrum-os.org/spectrum-devel/20260711-cgroups-v3-3-5cba61a20cba@gmail.com/
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 4dcc10b9933cdfaf87f87417db1de0daa57b73f5..f161c26e8b3cc3a46d3321d88a52c446e2faac96 100644

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

index at:
100644 f161c26e8b3cc3a46d3321d88a52c446e2faac96	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).