patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [PATCH 1/4] Introduce a build configuration file
@ 2022-08-31  9:37 Alyssa Ross
  2022-08-31  9:37 ` [PATCH 2/4] nix: prefer build configs from <spectrum-config> Alyssa Ross
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Alyssa Ross @ 2022-08-31  9:37 UTC (permalink / raw)
  To: devel; +Cc: José Pekkarinen, Ivan Nikolaenko

By default, a file called "config.nix" in the root of the Spectrum
repository will be read if it exists.  That file should contain an
attribute set.  Currently, only a "pkgs" key is supported, which
allows specifying a custom package set that will be used throughout
the Spectrum Nix files.  This will allow us to provide configuartion
options for people who want to build Spectrum in ways that are
probably not suitable for upstreaming.

For example, using the "pkgs" config option I'm introducing here, it
would be possible to use an overlay to patch individual components,
like so:

	{
	  pkgs = import <nixpkgs> {
	    overlays = [
	      (final: super: {
	        weston = super.weston.overrideAttrs ({ patches ? [], ... }: {
	          patches = patches ++ [
	            path/to/weston.patch
	          ];
	        });
	      })
	    ];
	  };
	}

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---

José, Ivan, if you'd like to review these patches, there's some
documentation on how to do so here: :)

https://spectrum-os.org/doc/reviewing-patches.html

 .gitignore                 |  1 +
 Documentation/default.nix  |  4 ++--
 Documentation/jekyll.nix   |  2 +-
 host/initramfs/default.nix |  7 +++----
 host/initramfs/extfs.nix   |  8 ++++----
 host/initramfs/shell.nix   |  9 +++++----
 host/rootfs/default.nix    |  7 +++++--
 host/rootfs/shell.nix      |  8 ++++----
 host/start-vm/default.nix  |  2 +-
 host/start-vm/shell.nix    |  6 +++---
 img/combined/default.nix   |  6 +++---
 img/combined/eosimages.nix |  4 ++--
 img/combined/run-vm.nix    |  4 ++--
 img/installer/default.nix  |  3 ++-
 img/installer/run-vm.nix   |  7 ++++---
 img/live/default.nix       | 11 ++++++-----
 img/live/shell.nix         | 15 +++++++++------
 nix/eval-config.nix        | 10 ++++++++++
 release.nix                | 10 +++++++---
 scripts/default.nix        |  4 ++--
 shell.nix                  |  2 +-
 vm/app/catgirl/default.nix |  6 +++---
 vm/app/catgirl/shell.nix   |  6 +++---
 vm/app/lynx/default.nix    |  6 +++---
 vm/app/lynx/shell.nix      |  6 +++---
 vm/sys/net/default.nix     |  6 +++---
 vm/sys/net/shell.nix       |  6 +++---
 27 files changed, 95 insertions(+), 71 deletions(-)
 create mode 100644 nix/eval-config.nix

diff --git a/.gitignore b/.gitignore
index 8b965e2..a97f309 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: CC0-1.0
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
+/config.nix
 build/
 result
 result-*
diff --git a/Documentation/default.nix b/Documentation/default.nix
index d94a8cd..9edfbe8 100644
--- a/Documentation/default.nix
+++ b/Documentation/default.nix
@@ -2,7 +2,7 @@
 # SPDX-FileCopyrightText: 2022 Unikie
 # SPDX-License-Identifier: MIT
 
-{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage (
+{ config ? import ../nix/eval-config.nix {} }: config.pkgs.callPackage (
 
 { lib, stdenvNoCC, jekyll, drawio-headless }:
 
@@ -31,5 +31,5 @@ stdenvNoCC.mkDerivation {
   passthru = { inherit jekyll; };
 }
 ) {
-  jekyll = import ./jekyll.nix { inherit pkgs; };
+  jekyll = import ./jekyll.nix { inherit config; };
 }
diff --git a/Documentation/jekyll.nix b/Documentation/jekyll.nix
index bc804b1..6f2866f 100644
--- a/Documentation/jekyll.nix
+++ b/Documentation/jekyll.nix
@@ -1,7 +1,7 @@
 # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 # SPDX-License-Identifier: MIT
 
-{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage (
+{ config ? import ../nix/eval-config.nix {} }: config.pkgs.callPackage (
 
 { bundlerApp }:
 
diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
index a4f7330..68deb5e 100644
--- a/host/initramfs/default.nix
+++ b/host/initramfs/default.nix
@@ -1,11 +1,10 @@
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 # SPDX-License-Identifier: MIT
 
-{ pkgs ? import <nixpkgs> {}
-, rootfs ? import ../rootfs { inherit pkgs; }
+{ config ? import ../../nix/eval-config.nix {}
+, rootfs ? import ../rootfs { inherit config; }
 }:
-
-pkgs.callPackage (
+let inherit (config) pkgs; in pkgs.callPackage (
 { lib, stdenvNoCC, makeModulesClosure, runCommand, writeReferencesToFile
 , pkgsStatic, busybox, cpio, cryptsetup, lvm2, microcodeAmd, microcodeIntel
 }:
diff --git a/host/initramfs/extfs.nix b/host/initramfs/extfs.nix
index 9fdbd9a..63f436a 100644
--- a/host/initramfs/extfs.nix
+++ b/host/initramfs/extfs.nix
@@ -1,21 +1,21 @@
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 # SPDX-License-Identifier: MIT
 
-{ pkgs, runCommand, tar2ext4 }:
+{ config, runCommand, tar2ext4 }:
 
 let
   netvm = import ../../vm/sys/net {
-    inherit pkgs;
+    inherit config;
     # inherit (foot) terminfo;
   };
 
   appvm-catgirl = import ../../vm/app/catgirl {
-    inherit pkgs;
+    inherit config;
     # inherit (foot) terminfo;
   };
 
   appvm-lynx = import ../../vm/app/lynx {
-    inherit pkgs;
+    inherit config;
     # inherit (foot) terminfo;
   };
 in
diff --git a/host/initramfs/shell.nix b/host/initramfs/shell.nix
index 42da6a4..cbd2c60 100644
--- a/host/initramfs/shell.nix
+++ b/host/initramfs/shell.nix
@@ -1,16 +1,17 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../nix/eval-config.nix {} }:
 
 let
+  inherit (config) pkgs;
   inherit (pkgs.lib) cleanSource cleanSourceWith;
 
   extfs = pkgs.pkgsStatic.callPackage ./extfs.nix {
-    inherit pkgs;
+    inherit config;
   };
-  rootfs = import ../rootfs { inherit pkgs; };
-  initramfs = import ./. { inherit pkgs rootfs; };
+  rootfs = import ../rootfs { inherit config; };
+  initramfs = import ./. { inherit config rootfs; };
 in
 
 with pkgs;
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index e5f316f..44e910b 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -2,7 +2,8 @@
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 # SPDX-FileCopyrightText: 2022 Unikie
 
-{ pkgs ? import <nixpkgs> {} }: pkgs.pkgsStatic.callPackage (
+{ config ? import ../../nix/eval-config.nix {} }: let inherit (config) pkgs; in
+pkgs.pkgsStatic.callPackage (
 
 { lib, stdenvNoCC, nixos, runCommand, writeReferencesToFile, s6-rc, tar2ext4
 , busybox, cloud-hypervisor, cryptsetup, execline, jq, kmod
@@ -13,7 +14,9 @@ let
   inherit (lib) cleanSource cleanSourceWith concatMapStringsSep hasSuffix;
   inherit (nixosAllHardware.config.hardware) firmware;
 
-  start-vm = import ../start-vm { pkgs = pkgs.pkgsStatic; };
+  start-vm = import ../start-vm {
+    config = config // { pkgs = pkgs.pkgsStatic; };
+  };
 
   pkgsGui = pkgs.pkgsMusl.extend (final: super: {
     systemd = final.libudev-zero;
diff --git a/host/rootfs/shell.nix b/host/rootfs/shell.nix
index 3b2310f..8c30f68 100644
--- a/host/rootfs/shell.nix
+++ b/host/rootfs/shell.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../nix/eval-config.nix {} }:
 
-with pkgs;
+with config.pkgs;
 
-(import ./. { inherit pkgs; }).overrideAttrs (
+(import ./. { inherit config; }).overrideAttrs (
 { passthru ? {}, nativeBuildInputs ? [], ... }:
 
 {
@@ -13,6 +13,6 @@ with pkgs;
     jq netcat qemu_kvm reuse util-linux
   ];
 
-  EXT_FS = pkgsStatic.callPackage ../initramfs/extfs.nix { inherit pkgs; };
+  EXT_FS = pkgsStatic.callPackage ../initramfs/extfs.nix { inherit config; };
   KERNEL = "${passthru.kernel}/${stdenv.hostPlatform.linux-kernel.target}";
 })
diff --git a/host/start-vm/default.nix b/host/start-vm/default.nix
index 56be882..fcce495 100644
--- a/host/start-vm/default.nix
+++ b/host/start-vm/default.nix
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage (
+{ config ? import ../../nix/eval-config.nix {} }: config.pkgs.callPackage (
 { lib, stdenv, fetchpatch, meson, ninja, rustc }:
 
 let
diff --git a/host/start-vm/shell.nix b/host/start-vm/shell.nix
index c7f6365..5192b76 100644
--- a/host/start-vm/shell.nix
+++ b/host/start-vm/shell.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../nix/eval-config.nix {} }:
 
-with pkgs;
+with config.pkgs;
 
-(import ./. { inherit pkgs; }).overrideAttrs (
+(import ./. { inherit config; }).overrideAttrs (
 { nativeBuildInputs ? [], ... }:
 
 {
diff --git a/img/combined/default.nix b/img/combined/default.nix
index 16cd506..3989d55 100644
--- a/img/combined/default.nix
+++ b/img/combined/default.nix
@@ -2,17 +2,17 @@
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 # SPDX-FileCopyrightText: 2021 Yureka <yuka@yuka.dev>
 
-{ pkgs ? import <nixpkgs> {} }: with pkgs;
+{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs;
 
 let
   inherit (builtins) storeDir;
   inherit (pkgs.lib) removePrefix;
 
-  eosimages = import ./eosimages.nix { inherit pkgs; };
+  eosimages = import ./eosimages.nix { inherit config; };
 
   installerPartUuid = "6e23b026-9f1e-479d-8a58-a0cda382e1ce";
   installer = import ../installer {
-    inherit pkgs;
+    inherit config;
 
     extraConfig = {
       boot.initrd.availableKernelModules = [ "squashfs" ];
diff --git a/img/combined/eosimages.nix b/img/combined/eosimages.nix
index 4ec28e5..9f2ab10 100644
--- a/img/combined/eosimages.nix
+++ b/img/combined/eosimages.nix
@@ -1,12 +1,12 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }: with pkgs;
+{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs;
 
 runCommand "eosimages.img" {
   nativeBuildInputs = [ e2fsprogs tar2ext4 ];
   imageName = "Spectrum-0.0-x86_64-generic.0.Live.img";
-  image = import ../live { inherit pkgs; };
+  image = import ../live { inherit config; };
 } ''
   mkdir dir
   cd dir
diff --git a/img/combined/run-vm.nix b/img/combined/run-vm.nix
index 893bc7d..40eacc4 100644
--- a/img/combined/run-vm.nix
+++ b/img/combined/run-vm.nix
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }: with pkgs;
+{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs;
 
 let
-  image = import ./. { inherit pkgs; };
+  image = import ./. { inherit config; };
 in
 
 writeShellScript "run-spectrum-installer-vm.sh" ''
diff --git a/img/installer/default.nix b/img/installer/default.nix
index ba97a53..0c57704 100644
--- a/img/installer/default.nix
+++ b/img/installer/default.nix
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {}, extraConfig ? {} }: with pkgs;
+{ config ? import ../../nix/eval-config.nix {}, extraConfig ? {} }:
+with config.pkgs;
 
 let
   inherit (builtins) head match storeDir;
diff --git a/img/installer/run-vm.nix b/img/installer/run-vm.nix
index 4a6c849..4efbf1a 100644
--- a/img/installer/run-vm.nix
+++ b/img/installer/run-vm.nix
@@ -1,17 +1,18 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../nix/eval-config.nix {} }:
 
 let
   inherit (builtins) storeDir;
+  inherit (config) pkgs;
   inherit (pkgs) coreutils qemu_kvm stdenv writeShellScript;
   inherit (pkgs.lib) makeBinPath escapeShellArg;
 
-  eosimages = import ../combined/eosimages.nix { inherit pkgs; };
+  eosimages = import ../combined/eosimages.nix { inherit config; };
 
   installer = import ./. {
-    inherit pkgs;
+    inherit config;
 
     extraConfig = {
       boot.initrd.availableKernelModules = [ "9p" "9pnet_virtio" ];
diff --git a/img/live/default.nix b/img/live/default.nix
index 88f0ee4..65ad058 100644
--- a/img/live/default.nix
+++ b/img/live/default.nix
@@ -1,17 +1,18 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../nix/eval-config.nix {} }:
 
 let
+  inherit (config) pkgs;
   inherit (pkgs.lib) cleanSource cleanSourceWith hasSuffix;
 
   extfs = pkgs.pkgsStatic.callPackage ../../host/initramfs/extfs.nix {
-    inherit pkgs;
+    inherit config;
   };
-  rootfs = import ../../host/rootfs { inherit pkgs; };
-  scripts = import ../../scripts { inherit pkgs; };
-  initramfs = import ../../host/initramfs { inherit pkgs rootfs; };
+  rootfs = import ../../host/rootfs { inherit config; };
+  scripts = import ../../scripts { inherit config; };
+  initramfs = import ../../host/initramfs { inherit config rootfs; };
 in
 
 with pkgs;
diff --git a/img/live/shell.nix b/img/live/shell.nix
index b9f0246..dcf2059 100644
--- a/img/live/shell.nix
+++ b/img/live/shell.nix
@@ -1,12 +1,15 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../nix/eval-config.nix {} }:
 
-with pkgs;
+with config.pkgs;
 
-(import ./. { inherit pkgs; }).overrideAttrs ({ nativeBuildInputs ? [], ... }: {
-  nativeBuildInputs = nativeBuildInputs ++ [ qemu_kvm ];
+(import ./. { inherit config; }).overrideAttrs (
+  { nativeBuildInputs ? [], ... }:
+  {
+    nativeBuildInputs = nativeBuildInputs ++ [ qemu_kvm ];
 
-  OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd";
-})
+    OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd";
+  }
+)
diff --git a/nix/eval-config.nix b/nix/eval-config.nix
new file mode 100644
index 0000000..9265df7
--- /dev/null
+++ b/nix/eval-config.nix
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2022 Unikie
+
+{ config ?
+  if builtins.pathExists ../config.nix then import ../config.nix else {}
+}:
+
+({ pkgs ? import <nixpkgs> {} }: {
+  inherit pkgs;
+}) config
diff --git a/release.nix b/release.nix
index da7123f..91a843b 100644
--- a/release.nix
+++ b/release.nix
@@ -3,10 +3,14 @@
 
 # This file is built to populate the binary cache.
 
-{ pkgs ? import <nixpkgs> {} }:
+# Set config = {} to disable implicitly reading config.nix, since
+# we'll want the result to be the same as on the binary cache.  If it
+# turns out there is a compelling reason to read the default config
+# here, we can reconsider this.
+{ config ? import nix/eval-config.nix { config = {}; } }:
 
 {
-  doc = import ./Documentation { inherit pkgs; };
+  doc = import ./Documentation { inherit config; };
 
-  combined = import img/combined/run-vm.nix { inherit pkgs; };
+  combined = import img/combined/run-vm.nix { inherit config; };
 }
diff --git a/scripts/default.nix b/scripts/default.nix
index 7995723..2237cb5 100644
--- a/scripts/default.nix
+++ b/scripts/default.nix
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../nix/eval-config.nix {} }:
 
 let
-  inherit (pkgs.lib) cleanSource cleanSourceWith hasSuffix;
+  inherit (config.pkgs.lib) cleanSource cleanSourceWith hasSuffix;
 in
 
 cleanSourceWith {
diff --git a/shell.nix b/shell.nix
index 41d0865..4dc8558 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,7 +1,7 @@
 # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 # SPDX-License-Identifier: MIT
 
-{ pkgs ? import <nixpkgs> {} }: with pkgs;
+{ config ? import nix/eval-config.nix {} }: with config.pkgs;
 
 mkShell {
   nativeBuildInputs = [ reuse rustfmt ];
diff --git a/vm/app/catgirl/default.nix b/vm/app/catgirl/default.nix
index 738a603..61f1462 100644
--- a/vm/app/catgirl/default.nix
+++ b/vm/app/catgirl/default.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {}
-, terminfo ? pkgs.foot.terminfo
+{ config ? import ../../../nix/eval-config.nix {}
+, terminfo ? config.pkgs.foot.terminfo
 }:
 
-pkgs.pkgsStatic.callPackage (
+config.pkgs.pkgsStatic.callPackage (
 
 { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
 , s6-rc, tar2ext4
diff --git a/vm/app/catgirl/shell.nix b/vm/app/catgirl/shell.nix
index 87c4f6e..852b246 100644
--- a/vm/app/catgirl/shell.nix
+++ b/vm/app/catgirl/shell.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../../nix/eval-config.nix {} }:
 
-with pkgs;
+with config.pkgs;
 
-(import ./. { inherit pkgs; }).overrideAttrs (
+(import ./. { inherit config; }).overrideAttrs (
 { passthru ? {}, nativeBuildInputs ? [], ... }:
 
 {
diff --git a/vm/app/lynx/default.nix b/vm/app/lynx/default.nix
index 50fd760..ba715ec 100644
--- a/vm/app/lynx/default.nix
+++ b/vm/app/lynx/default.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {}
-, terminfo ? pkgs.foot.terminfo
+{ config ? import ../../../nix/eval-config.nix {}
+, terminfo ? config.pkgs.foot.terminfo
 }:
 
-pkgs.pkgsStatic.callPackage (
+config.pkgs.pkgsStatic.callPackage (
 
 { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
 , s6-rc, tar2ext4
diff --git a/vm/app/lynx/shell.nix b/vm/app/lynx/shell.nix
index 87c4f6e..852b246 100644
--- a/vm/app/lynx/shell.nix
+++ b/vm/app/lynx/shell.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../../nix/eval-config.nix {} }:
 
-with pkgs;
+with config.pkgs;
 
-(import ./. { inherit pkgs; }).overrideAttrs (
+(import ./. { inherit config; }).overrideAttrs (
 { passthru ? {}, nativeBuildInputs ? [], ... }:
 
 {
diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
index 0ce72fc..dfc7c35 100644
--- a/vm/sys/net/default.nix
+++ b/vm/sys/net/default.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {}
-, terminfo ? pkgs.foot.terminfo
+{ config ? import ../../../nix/eval-config.nix {}
+, terminfo ? config.pkgs.foot.terminfo
 }:
 
-pkgs.pkgsStatic.callPackage (
+config.pkgs.pkgsStatic.callPackage (
 
 { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
 , s6-rc, tar2ext4, xorg
diff --git a/vm/sys/net/shell.nix b/vm/sys/net/shell.nix
index bc4de67..849920d 100644
--- a/vm/sys/net/shell.nix
+++ b/vm/sys/net/shell.nix
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: MIT
 # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
 
-{ pkgs ? import <nixpkgs> {} }:
+{ config ? import ../../../nix/eval-config.nix {} }:
 
-with pkgs;
+with config.pkgs;
 
-(import ./. { inherit pkgs; }).overrideAttrs (
+(import ./. { inherit config; }).overrideAttrs (
 { passthru ? {}, nativeBuildInputs ? [], ... }:
 
 {
-- 
2.37.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/4] nix: prefer build configs from <spectrum-config>
  2022-08-31  9:37 [PATCH 1/4] Introduce a build configuration file Alyssa Ross
@ 2022-08-31  9:37 ` Alyssa Ross
  2022-09-08 11:40   ` José Pekkarinen
  2022-09-14  6:58   ` Alyssa Ross
  2022-08-31  9:37 ` [PATCH 3/4] Documentation/jekyll: patch for AsciiDoc examples Alyssa Ross
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Alyssa Ross @ 2022-08-31  9:37 UTC (permalink / raw)
  To: devel; +Cc: José Pekkarinen, Ivan Nikolaenko

This will make it easier to use multiple configs, e.g. for different
boards.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
 nix/eval-config.nix | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/nix/eval-config.nix b/nix/eval-config.nix
index 9265df7..467f877 100644
--- a/nix/eval-config.nix
+++ b/nix/eval-config.nix
@@ -2,7 +2,10 @@
 # SPDX-FileCopyrightText: 2022 Unikie
 
 { config ?
-  if builtins.pathExists ../config.nix then import ../config.nix else {}
+  let customPath = builtins.tryEval <spectrum-config>; in
+  if customPath.success then import customPath.value
+  else if builtins.pathExists ../config.nix then import ../config.nix
+  else {}
 }:
 
 ({ pkgs ? import <nixpkgs> {} }: {
-- 
2.37.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/4] Documentation/jekyll: patch for AsciiDoc examples
  2022-08-31  9:37 [PATCH 1/4] Introduce a build configuration file Alyssa Ross
  2022-08-31  9:37 ` [PATCH 2/4] nix: prefer build configs from <spectrum-config> Alyssa Ross
@ 2022-08-31  9:37 ` Alyssa Ross
  2022-09-14  7:03   ` Alyssa Ross
  2022-08-31  9:37 ` [PATCH 4/4] Documentation: document build configuration file Alyssa Ross
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Alyssa Ross @ 2022-08-31  9:37 UTC (permalink / raw)
  To: devel; +Cc: José Pekkarinen, Ivan Nikolaenko

The documentation I would like to add for the build configuration file
uses a titled example, which doesn't render nicely with Just The Docs
without this change.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
 Documentation/jekyll.nix | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/Documentation/jekyll.nix b/Documentation/jekyll.nix
index 6f2866f..16c2c38 100644
--- a/Documentation/jekyll.nix
+++ b/Documentation/jekyll.nix
@@ -3,11 +3,39 @@
 
 { config ? import ../nix/eval-config.nix {} }: config.pkgs.callPackage (
 
-{ bundlerApp }:
+{ lib, bundlerApp, defaultGemConfig, fetchFromGitHub, fetchpatch }:
 
 bundlerApp {
   pname = "jekyll";
   gemdir = ./.;
   exes = [ "jekyll" ];
+
+  gemConfig = defaultGemConfig // {
+    # We override Just the Docs to improve AsciiDoc support.
+    just-the-docs = attrs:
+      let super = defaultGemConfig.just-the-docs or (lib.const {}) attrs; in
+      super // {
+        # The gem tarball doesn't contain e.g. the SCSS files.
+        src = fetchFromGitHub {
+          owner = "just-the-docs";
+          repo = "just-the-docs";
+          rev ="v${attrs.version}";
+          sha256 = assert attrs.version == "0.4.0.rc1"; "sUgwPio5Lukd8c0dR5kbRxW5vT/ctO69lbyg+AvcUbQ=";
+        };
+
+        patches = super.patches or attrs.patches or [] ++ [
+          # https://github.com/just-the-docs/just-the-docs/pull/944
+          (fetchpatch {
+            url = "https://github.com/alyssais/just-the-docs/commit/6bf1f26ab70b6a12fd090b99cda85f557da837eb.patch";
+            sha256 = "jv3I7Unu6ZMl0hjvBlvTWIVH8cYfO3cVS1BoJnYWo+U=";
+          })
+        ];
+
+        postPatch = ''
+          substituteInPlace just-the-docs.gemspec \
+              --replace 'git ls-files -z' 'find * -print0'
+        '';
+      };
+  };
 }
 ) { }
-- 
2.37.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/4] Documentation: document build configuration file
  2022-08-31  9:37 [PATCH 1/4] Introduce a build configuration file Alyssa Ross
  2022-08-31  9:37 ` [PATCH 2/4] nix: prefer build configs from <spectrum-config> Alyssa Ross
  2022-08-31  9:37 ` [PATCH 3/4] Documentation/jekyll: patch for AsciiDoc examples Alyssa Ross
@ 2022-08-31  9:37 ` Alyssa Ross
  2022-09-14  6:58   ` Alyssa Ross
  2022-09-06  5:53 ` [PATCH 1/4] Introduce a " Ville Ilvonen
  2022-09-14  6:58 ` Alyssa Ross
  4 siblings, 1 reply; 11+ messages in thread
From: Alyssa Ross @ 2022-08-31  9:37 UTC (permalink / raw)
  To: devel; +Cc: José Pekkarinen, Ivan Nikolaenko, Evgeniia Nikolaenko

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---

There's some documentation on reviewing patches for Spectrum here: :)
https://spectrum-os.org/doc/reviewing-patches.html

 Documentation/build-configuration.adoc | 35 ++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/build-configuration.adoc

diff --git a/Documentation/build-configuration.adoc b/Documentation/build-configuration.adoc
new file mode 100644
index 0000000..db68c34
--- /dev/null
+++ b/Documentation/build-configuration.adoc
@@ -0,0 +1,35 @@
+= Configuring the Build
+:page-parent: How-to Guides
+:example-caption: Test
+
+// SPDX-FileCopyrightText: 2022 Unikie
+// SPDX-License-Identifier: GFDL-1.3-no-invariants-or-later OR CC-BY-SA-4.0
+
+Some aspects of a Spectrum build can be customised using a build
+configuration file.  By default, this configuration file should be
+called config.nix and located in the root of the Spectrum source tree,
+but this path can be overridden by setting `spectrum-config` in the
+https://nixos.org/manual/nix/stable/command-ref/env-common.html#env-NIX_PATH[NIX_PATH].
+
+The configuration file should contain an attribute set.  The only
+currently allowed attribute name is `pkgs`, which allows using a
+custom Nixpkgs to evaluate Spectrum.
+
+.config.nix to build Spectrum with a https://nixos.org/manual/nixpkgs/unstable/#sec-overlays-definition[Nixpkgs overlay]
+[example]
+[source,nix]
+----
+{
+  pkgs = import <nixpkgs> {
+    overlays = [
+      (final: super: {
+        weston = super.weston.overrideAttrs ({ patches ? [], ... }: {
+          patches = patches ++ [
+            path/to/weston.patch
+          ];
+        });
+      })
+    ];
+  };
+}
+----
-- 
2.37.1



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] Introduce a build configuration file
  2022-08-31  9:37 [PATCH 1/4] Introduce a build configuration file Alyssa Ross
                   ` (2 preceding siblings ...)
  2022-08-31  9:37 ` [PATCH 4/4] Documentation: document build configuration file Alyssa Ross
@ 2022-09-06  5:53 ` Ville Ilvonen
       [not found]   ` <87fsh5c60x.fsf@alyssa.is>
  2022-09-14  6:58 ` Alyssa Ross
  4 siblings, 1 reply; 11+ messages in thread
From: Ville Ilvonen @ 2022-09-06  5:53 UTC (permalink / raw)
  To: Alyssa Ross, devel; +Cc: José Pekkarinen, Ivan Nikolaenko

On 8/31/22 12:37, Alyssa Ross wrote:
> By default, a file called "config.nix" in the root of the Spectrum
> repository will be read if it exists.  That file should contain an
> attribute set.  Currently, only a "pkgs" key is supported, which
> allows specifying a custom package set that will be used throughout
> the Spectrum Nix files.  This will allow us to provide configuartion
> options for people who want to build Spectrum in ways that are
> probably not suitable for upstreaming.
 >
> For example, using the "pkgs" config option I'm introducing here, it
> would be possible to use an overlay to patch individual components,
> like so:
> 
> 	{
> 	  pkgs = import <nixpkgs> {
> 	    overlays = [
> 	      (final: super: {
> 	        weston = super.weston.overrideAttrs ({ patches ? [], ... }: {
> 	          patches = patches ++ [
> 	            path/to/weston.patch
> 	          ];
> 	        });
> 	      })
> 	    ];
> 	  };
> 	}
> 
> Signed-off-by: Alyssa Ross <hi@alyssa.is>
> ---

Appreciate it as this makes it more clean to implement device specifics. 
Would you like to see the device specific configs in tree or out of 
tree? One option would be to set the default config and support in tree 
configs of devices people could choose from. Even if not fully supported 
by upstream, they could be useful as examples. If both are possible, 
criteria for guiding in-tree and out-of-tree configs could be also useful.

Thanks,

-Ville

Reviewed-by: Ville Ilvonen <ville.ilvonen@unikie.com>

> José, Ivan, if you'd like to review these patches, there's some
> documentation on how to do so here: :)
> 
> https://spectrum-os.org/doc/reviewing-patches.html
> 
>   .gitignore                 |  1 +
>   Documentation/default.nix  |  4 ++--
>   Documentation/jekyll.nix   |  2 +-
>   host/initramfs/default.nix |  7 +++----
>   host/initramfs/extfs.nix   |  8 ++++----
>   host/initramfs/shell.nix   |  9 +++++----
>   host/rootfs/default.nix    |  7 +++++--
>   host/rootfs/shell.nix      |  8 ++++----
>   host/start-vm/default.nix  |  2 +-
>   host/start-vm/shell.nix    |  6 +++---
>   img/combined/default.nix   |  6 +++---
>   img/combined/eosimages.nix |  4 ++--
>   img/combined/run-vm.nix    |  4 ++--
>   img/installer/default.nix  |  3 ++-
>   img/installer/run-vm.nix   |  7 ++++---
>   img/live/default.nix       | 11 ++++++-----
>   img/live/shell.nix         | 15 +++++++++------
>   nix/eval-config.nix        | 10 ++++++++++
>   release.nix                | 10 +++++++---
>   scripts/default.nix        |  4 ++--
>   shell.nix                  |  2 +-
>   vm/app/catgirl/default.nix |  6 +++---
>   vm/app/catgirl/shell.nix   |  6 +++---
>   vm/app/lynx/default.nix    |  6 +++---
>   vm/app/lynx/shell.nix      |  6 +++---
>   vm/sys/net/default.nix     |  6 +++---
>   vm/sys/net/shell.nix       |  6 +++---
>   27 files changed, 95 insertions(+), 71 deletions(-)
>   create mode 100644 nix/eval-config.nix
> 
> diff --git a/.gitignore b/.gitignore
> index 8b965e2..a97f309 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -1,6 +1,7 @@
>   # SPDX-License-Identifier: CC0-1.0
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> +/config.nix
>   build/
>   result
>   result-*
> diff --git a/Documentation/default.nix b/Documentation/default.nix
> index d94a8cd..9edfbe8 100644
> --- a/Documentation/default.nix
> +++ b/Documentation/default.nix
> @@ -2,7 +2,7 @@
>   # SPDX-FileCopyrightText: 2022 Unikie
>   # SPDX-License-Identifier: MIT
>   
> -{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage (
> +{ config ? import ../nix/eval-config.nix {} }: config.pkgs.callPackage (
>   
>   { lib, stdenvNoCC, jekyll, drawio-headless }:
>   
> @@ -31,5 +31,5 @@ stdenvNoCC.mkDerivation {
>     passthru = { inherit jekyll; };
>   }
>   ) {
> -  jekyll = import ./jekyll.nix { inherit pkgs; };
> +  jekyll = import ./jekyll.nix { inherit config; };
>   }
> diff --git a/Documentation/jekyll.nix b/Documentation/jekyll.nix
> index bc804b1..6f2866f 100644
> --- a/Documentation/jekyll.nix
> +++ b/Documentation/jekyll.nix
> @@ -1,7 +1,7 @@
>   # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
>   # SPDX-License-Identifier: MIT
>   
> -{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage (
> +{ config ? import ../nix/eval-config.nix {} }: config.pkgs.callPackage (
>   
>   { bundlerApp }:
>   
> diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
> index a4f7330..68deb5e 100644
> --- a/host/initramfs/default.nix
> +++ b/host/initramfs/default.nix
> @@ -1,11 +1,10 @@
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   # SPDX-License-Identifier: MIT
>   
> -{ pkgs ? import <nixpkgs> {}
> -, rootfs ? import ../rootfs { inherit pkgs; }
> +{ config ? import ../../nix/eval-config.nix {}
> +, rootfs ? import ../rootfs { inherit config; }
>   }:
> -
> -pkgs.callPackage (
> +let inherit (config) pkgs; in pkgs.callPackage (
>   { lib, stdenvNoCC, makeModulesClosure, runCommand, writeReferencesToFile
>   , pkgsStatic, busybox, cpio, cryptsetup, lvm2, microcodeAmd, microcodeIntel
>   }:
> diff --git a/host/initramfs/extfs.nix b/host/initramfs/extfs.nix
> index 9fdbd9a..63f436a 100644
> --- a/host/initramfs/extfs.nix
> +++ b/host/initramfs/extfs.nix
> @@ -1,21 +1,21 @@
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   # SPDX-License-Identifier: MIT
>   
> -{ pkgs, runCommand, tar2ext4 }:
> +{ config, runCommand, tar2ext4 }:
>   
>   let
>     netvm = import ../../vm/sys/net {
> -    inherit pkgs;
> +    inherit config;
>       # inherit (foot) terminfo;
>     };
>   
>     appvm-catgirl = import ../../vm/app/catgirl {
> -    inherit pkgs;
> +    inherit config;
>       # inherit (foot) terminfo;
>     };
>   
>     appvm-lynx = import ../../vm/app/lynx {
> -    inherit pkgs;
> +    inherit config;
>       # inherit (foot) terminfo;
>     };
>   in
> diff --git a/host/initramfs/shell.nix b/host/initramfs/shell.nix
> index 42da6a4..cbd2c60 100644
> --- a/host/initramfs/shell.nix
> +++ b/host/initramfs/shell.nix
> @@ -1,16 +1,17 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../nix/eval-config.nix {} }:
>   
>   let
> +  inherit (config) pkgs;
>     inherit (pkgs.lib) cleanSource cleanSourceWith;
>   
>     extfs = pkgs.pkgsStatic.callPackage ./extfs.nix {
> -    inherit pkgs;
> +    inherit config;
>     };
> -  rootfs = import ../rootfs { inherit pkgs; };
> -  initramfs = import ./. { inherit pkgs rootfs; };
> +  rootfs = import ../rootfs { inherit config; };
> +  initramfs = import ./. { inherit config rootfs; };
>   in
>   
>   with pkgs;
> diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
> index e5f316f..44e910b 100644
> --- a/host/rootfs/default.nix
> +++ b/host/rootfs/default.nix
> @@ -2,7 +2,8 @@
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   # SPDX-FileCopyrightText: 2022 Unikie
>   
> -{ pkgs ? import <nixpkgs> {} }: pkgs.pkgsStatic.callPackage (
> +{ config ? import ../../nix/eval-config.nix {} }: let inherit (config) pkgs; in
> +pkgs.pkgsStatic.callPackage (
>   
>   { lib, stdenvNoCC, nixos, runCommand, writeReferencesToFile, s6-rc, tar2ext4
>   , busybox, cloud-hypervisor, cryptsetup, execline, jq, kmod
> @@ -13,7 +14,9 @@ let
>     inherit (lib) cleanSource cleanSourceWith concatMapStringsSep hasSuffix;
>     inherit (nixosAllHardware.config.hardware) firmware;
>   
> -  start-vm = import ../start-vm { pkgs = pkgs.pkgsStatic; };
> +  start-vm = import ../start-vm {
> +    config = config // { pkgs = pkgs.pkgsStatic; };
> +  };
>   
>     pkgsGui = pkgs.pkgsMusl.extend (final: super: {
>       systemd = final.libudev-zero;
> diff --git a/host/rootfs/shell.nix b/host/rootfs/shell.nix
> index 3b2310f..8c30f68 100644
> --- a/host/rootfs/shell.nix
> +++ b/host/rootfs/shell.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../nix/eval-config.nix {} }:
>   
> -with pkgs;
> +with config.pkgs;
>   
> -(import ./. { inherit pkgs; }).overrideAttrs (
> +(import ./. { inherit config; }).overrideAttrs (
>   { passthru ? {}, nativeBuildInputs ? [], ... }:
>   
>   {
> @@ -13,6 +13,6 @@ with pkgs;
>       jq netcat qemu_kvm reuse util-linux
>     ];
>   
> -  EXT_FS = pkgsStatic.callPackage ../initramfs/extfs.nix { inherit pkgs; };
> +  EXT_FS = pkgsStatic.callPackage ../initramfs/extfs.nix { inherit config; };
>     KERNEL = "${passthru.kernel}/${stdenv.hostPlatform.linux-kernel.target}";
>   })
> diff --git a/host/start-vm/default.nix b/host/start-vm/default.nix
> index 56be882..fcce495 100644
> --- a/host/start-vm/default.nix
> +++ b/host/start-vm/default.nix
> @@ -1,7 +1,7 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }: pkgs.callPackage (
> +{ config ? import ../../nix/eval-config.nix {} }: config.pkgs.callPackage (
>   { lib, stdenv, fetchpatch, meson, ninja, rustc }:
>   
>   let
> diff --git a/host/start-vm/shell.nix b/host/start-vm/shell.nix
> index c7f6365..5192b76 100644
> --- a/host/start-vm/shell.nix
> +++ b/host/start-vm/shell.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../nix/eval-config.nix {} }:
>   
> -with pkgs;
> +with config.pkgs;
>   
> -(import ./. { inherit pkgs; }).overrideAttrs (
> +(import ./. { inherit config; }).overrideAttrs (
>   { nativeBuildInputs ? [], ... }:
>   
>   {
> diff --git a/img/combined/default.nix b/img/combined/default.nix
> index 16cd506..3989d55 100644
> --- a/img/combined/default.nix
> +++ b/img/combined/default.nix
> @@ -2,17 +2,17 @@
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   # SPDX-FileCopyrightText: 2021 Yureka <yuka@yuka.dev>
>   
> -{ pkgs ? import <nixpkgs> {} }: with pkgs;
> +{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs;
>   
>   let
>     inherit (builtins) storeDir;
>     inherit (pkgs.lib) removePrefix;
>   
> -  eosimages = import ./eosimages.nix { inherit pkgs; };
> +  eosimages = import ./eosimages.nix { inherit config; };
>   
>     installerPartUuid = "6e23b026-9f1e-479d-8a58-a0cda382e1ce";
>     installer = import ../installer {
> -    inherit pkgs;
> +    inherit config;
>   
>       extraConfig = {
>         boot.initrd.availableKernelModules = [ "squashfs" ];
> diff --git a/img/combined/eosimages.nix b/img/combined/eosimages.nix
> index 4ec28e5..9f2ab10 100644
> --- a/img/combined/eosimages.nix
> +++ b/img/combined/eosimages.nix
> @@ -1,12 +1,12 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }: with pkgs;
> +{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs;
>   
>   runCommand "eosimages.img" {
>     nativeBuildInputs = [ e2fsprogs tar2ext4 ];
>     imageName = "Spectrum-0.0-x86_64-generic.0.Live.img";
> -  image = import ../live { inherit pkgs; };
> +  image = import ../live { inherit config; };
>   } ''
>     mkdir dir
>     cd dir
> diff --git a/img/combined/run-vm.nix b/img/combined/run-vm.nix
> index 893bc7d..40eacc4 100644
> --- a/img/combined/run-vm.nix
> +++ b/img/combined/run-vm.nix
> @@ -1,10 +1,10 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }: with pkgs;
> +{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs;
>   
>   let
> -  image = import ./. { inherit pkgs; };
> +  image = import ./. { inherit config; };
>   in
>   
>   writeShellScript "run-spectrum-installer-vm.sh" ''
> diff --git a/img/installer/default.nix b/img/installer/default.nix
> index ba97a53..0c57704 100644
> --- a/img/installer/default.nix
> +++ b/img/installer/default.nix
> @@ -1,7 +1,8 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {}, extraConfig ? {} }: with pkgs;
> +{ config ? import ../../nix/eval-config.nix {}, extraConfig ? {} }:
> +with config.pkgs;
>   
>   let
>     inherit (builtins) head match storeDir;
> diff --git a/img/installer/run-vm.nix b/img/installer/run-vm.nix
> index 4a6c849..4efbf1a 100644
> --- a/img/installer/run-vm.nix
> +++ b/img/installer/run-vm.nix
> @@ -1,17 +1,18 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../nix/eval-config.nix {} }:
>   
>   let
>     inherit (builtins) storeDir;
> +  inherit (config) pkgs;
>     inherit (pkgs) coreutils qemu_kvm stdenv writeShellScript;
>     inherit (pkgs.lib) makeBinPath escapeShellArg;
>   
> -  eosimages = import ../combined/eosimages.nix { inherit pkgs; };
> +  eosimages = import ../combined/eosimages.nix { inherit config; };
>   
>     installer = import ./. {
> -    inherit pkgs;
> +    inherit config;
>   
>       extraConfig = {
>         boot.initrd.availableKernelModules = [ "9p" "9pnet_virtio" ];
> diff --git a/img/live/default.nix b/img/live/default.nix
> index 88f0ee4..65ad058 100644
> --- a/img/live/default.nix
> +++ b/img/live/default.nix
> @@ -1,17 +1,18 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../nix/eval-config.nix {} }:
>   
>   let
> +  inherit (config) pkgs;
>     inherit (pkgs.lib) cleanSource cleanSourceWith hasSuffix;
>   
>     extfs = pkgs.pkgsStatic.callPackage ../../host/initramfs/extfs.nix {
> -    inherit pkgs;
> +    inherit config;
>     };
> -  rootfs = import ../../host/rootfs { inherit pkgs; };
> -  scripts = import ../../scripts { inherit pkgs; };
> -  initramfs = import ../../host/initramfs { inherit pkgs rootfs; };
> +  rootfs = import ../../host/rootfs { inherit config; };
> +  scripts = import ../../scripts { inherit config; };
> +  initramfs = import ../../host/initramfs { inherit config rootfs; };
>   in
>   
>   with pkgs;
> diff --git a/img/live/shell.nix b/img/live/shell.nix
> index b9f0246..dcf2059 100644
> --- a/img/live/shell.nix
> +++ b/img/live/shell.nix
> @@ -1,12 +1,15 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../nix/eval-config.nix {} }:
>   
> -with pkgs;
> +with config.pkgs;
>   
> -(import ./. { inherit pkgs; }).overrideAttrs ({ nativeBuildInputs ? [], ... }: {
> -  nativeBuildInputs = nativeBuildInputs ++ [ qemu_kvm ];
> +(import ./. { inherit config; }).overrideAttrs (
> +  { nativeBuildInputs ? [], ... }:
> +  {
> +    nativeBuildInputs = nativeBuildInputs ++ [ qemu_kvm ];
>   
> -  OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd";
> -})
> +    OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd";
> +  }
> +)
> diff --git a/nix/eval-config.nix b/nix/eval-config.nix
> new file mode 100644
> index 0000000..9265df7
> --- /dev/null
> +++ b/nix/eval-config.nix
> @@ -0,0 +1,10 @@
> +# SPDX-License-Identifier: MIT
> +# SPDX-FileCopyrightText: 2022 Unikie
> +
> +{ config ?
> +  if builtins.pathExists ../config.nix then import ../config.nix else {}
> +}:
> +
> +({ pkgs ? import <nixpkgs> {} }: {
> +  inherit pkgs;
> +}) config
> diff --git a/release.nix b/release.nix
> index da7123f..91a843b 100644
> --- a/release.nix
> +++ b/release.nix
> @@ -3,10 +3,14 @@
>   
>   # This file is built to populate the binary cache.
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +# Set config = {} to disable implicitly reading config.nix, since
> +# we'll want the result to be the same as on the binary cache.  If it
> +# turns out there is a compelling reason to read the default config
> +# here, we can reconsider this.
> +{ config ? import nix/eval-config.nix { config = {}; } }:
>   
>   {
> -  doc = import ./Documentation { inherit pkgs; };
> +  doc = import ./Documentation { inherit config; };
>   
> -  combined = import img/combined/run-vm.nix { inherit pkgs; };
> +  combined = import img/combined/run-vm.nix { inherit config; };
>   }
> diff --git a/scripts/default.nix b/scripts/default.nix
> index 7995723..2237cb5 100644
> --- a/scripts/default.nix
> +++ b/scripts/default.nix
> @@ -1,10 +1,10 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../nix/eval-config.nix {} }:
>   
>   let
> -  inherit (pkgs.lib) cleanSource cleanSourceWith hasSuffix;
> +  inherit (config.pkgs.lib) cleanSource cleanSourceWith hasSuffix;
>   in
>   
>   cleanSourceWith {
> diff --git a/shell.nix b/shell.nix
> index 41d0865..4dc8558 100644
> --- a/shell.nix
> +++ b/shell.nix
> @@ -1,7 +1,7 @@
>   # SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
>   # SPDX-License-Identifier: MIT
>   
> -{ pkgs ? import <nixpkgs> {} }: with pkgs;
> +{ config ? import nix/eval-config.nix {} }: with config.pkgs;
>   
>   mkShell {
>     nativeBuildInputs = [ reuse rustfmt ];
> diff --git a/vm/app/catgirl/default.nix b/vm/app/catgirl/default.nix
> index 738a603..61f1462 100644
> --- a/vm/app/catgirl/default.nix
> +++ b/vm/app/catgirl/default.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {}
> -, terminfo ? pkgs.foot.terminfo
> +{ config ? import ../../../nix/eval-config.nix {}
> +, terminfo ? config.pkgs.foot.terminfo
>   }:
>   
> -pkgs.pkgsStatic.callPackage (
> +config.pkgs.pkgsStatic.callPackage (
>   
>   { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
>   , s6-rc, tar2ext4
> diff --git a/vm/app/catgirl/shell.nix b/vm/app/catgirl/shell.nix
> index 87c4f6e..852b246 100644
> --- a/vm/app/catgirl/shell.nix
> +++ b/vm/app/catgirl/shell.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../../nix/eval-config.nix {} }:
>   
> -with pkgs;
> +with config.pkgs;
>   
> -(import ./. { inherit pkgs; }).overrideAttrs (
> +(import ./. { inherit config; }).overrideAttrs (
>   { passthru ? {}, nativeBuildInputs ? [], ... }:
>   
>   {
> diff --git a/vm/app/lynx/default.nix b/vm/app/lynx/default.nix
> index 50fd760..ba715ec 100644
> --- a/vm/app/lynx/default.nix
> +++ b/vm/app/lynx/default.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {}
> -, terminfo ? pkgs.foot.terminfo
> +{ config ? import ../../../nix/eval-config.nix {}
> +, terminfo ? config.pkgs.foot.terminfo
>   }:
>   
> -pkgs.pkgsStatic.callPackage (
> +config.pkgs.pkgsStatic.callPackage (
>   
>   { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
>   , s6-rc, tar2ext4
> diff --git a/vm/app/lynx/shell.nix b/vm/app/lynx/shell.nix
> index 87c4f6e..852b246 100644
> --- a/vm/app/lynx/shell.nix
> +++ b/vm/app/lynx/shell.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../../nix/eval-config.nix {} }:
>   
> -with pkgs;
> +with config.pkgs;
>   
> -(import ./. { inherit pkgs; }).overrideAttrs (
> +(import ./. { inherit config; }).overrideAttrs (
>   { passthru ? {}, nativeBuildInputs ? [], ... }:
>   
>   {
> diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
> index 0ce72fc..dfc7c35 100644
> --- a/vm/sys/net/default.nix
> +++ b/vm/sys/net/default.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {}
> -, terminfo ? pkgs.foot.terminfo
> +{ config ? import ../../../nix/eval-config.nix {}
> +, terminfo ? config.pkgs.foot.terminfo
>   }:
>   
> -pkgs.pkgsStatic.callPackage (
> +config.pkgs.pkgsStatic.callPackage (
>   
>   { lib, stdenvNoCC, runCommand, writeReferencesToFile, buildPackages
>   , s6-rc, tar2ext4, xorg
> diff --git a/vm/sys/net/shell.nix b/vm/sys/net/shell.nix
> index bc4de67..849920d 100644
> --- a/vm/sys/net/shell.nix
> +++ b/vm/sys/net/shell.nix
> @@ -1,11 +1,11 @@
>   # SPDX-License-Identifier: MIT
>   # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
>   
> -{ pkgs ? import <nixpkgs> {} }:
> +{ config ? import ../../../nix/eval-config.nix {} }:
>   
> -with pkgs;
> +with config.pkgs;
>   
> -(import ./. { inherit pkgs; }).overrideAttrs (
> +(import ./. { inherit config; }).overrideAttrs (
>   { passthru ? {}, nativeBuildInputs ? [], ... }:
>   
>   {




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] Introduce a build configuration file
       [not found]   ` <87fsh5c60x.fsf@alyssa.is>
@ 2022-09-08 11:39     ` José Pekkarinen
  0 siblings, 0 replies; 11+ messages in thread
From: José Pekkarinen @ 2022-09-08 11:39 UTC (permalink / raw)
  To: Alyssa Ross; +Cc: Ville Ilvonen, devel, Ivan Nikolaenko

[-- Attachment #1: Type: text/plain, Size: 2087 bytes --]

On Tue, Sep 6, 2022 at 10:32 AM Alyssa Ross <hi@alyssa.is> wrote:

> Ville Ilvonen <ville.ilvonen@unikie.com> writes:
>
> > On 8/31/22 12:37, Alyssa Ross wrote:
> >> By default, a file called "config.nix" in the root of the Spectrum
> >> repository will be read if it exists.  That file should contain an
> >> attribute set.  Currently, only a "pkgs" key is supported, which
> >> allows specifying a custom package set that will be used throughout
> >> the Spectrum Nix files.  This will allow us to provide configuartion
> >> options for people who want to build Spectrum in ways that are
> >> probably not suitable for upstreaming.
> >  >
> >> For example, using the "pkgs" config option I'm introducing here, it
> >> would be possible to use an overlay to patch individual components,
> >> like so:
> >>
> >>      {
> >>        pkgs = import <nixpkgs> {
> >>          overlays = [
> >>            (final: super: {
> >>              weston = super.weston.overrideAttrs ({ patches ? [], ...
> }: {
> >>                patches = patches ++ [
> >>                  path/to/weston.patch
> >>                ];
> >>              });
> >>            })
> >>          ];
> >>        };
> >>      }
> >>
> >> Signed-off-by: Alyssa Ross <hi@alyssa.is>
>

Tested-by: José Pekkarinen <jose.pekkarinen@unikie.com>

>> ---
> >
> > Appreciate it as this makes it more clean to implement device specifics.
> > Would you like to see the device specific configs in tree or out of
> > tree? One option would be to set the default config and support in tree
> > configs of devices people could choose from. Even if not fully supported
> > by upstream, they could be useful as examples. If both are possible,
> > criteria for guiding in-tree and out-of-tree configs could be also
> useful.
>
> I'm not sure yet.  Let's maybe revisit once we have generic ARM support
> in-tree, and see how it feels then?
>
> > Thanks,
> >
> > -Ville
> >
> > Reviewed-by: Ville Ilvonen <ville.ilvonen@unikie.com>
>
> Thanks for the review. :)
>


-- 

José.

[-- Attachment #2: Type: text/html, Size: 3430 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] nix: prefer build configs from <spectrum-config>
  2022-08-31  9:37 ` [PATCH 2/4] nix: prefer build configs from <spectrum-config> Alyssa Ross
@ 2022-09-08 11:40   ` José Pekkarinen
  2022-09-14  6:58   ` Alyssa Ross
  1 sibling, 0 replies; 11+ messages in thread
From: José Pekkarinen @ 2022-09-08 11:40 UTC (permalink / raw)
  To: Alyssa Ross; +Cc: devel, Ivan Nikolaenko

[-- Attachment #1: Type: text/plain, Size: 964 bytes --]

On Wed, Aug 31, 2022 at 12:38 PM Alyssa Ross <hi@alyssa.is> wrote:

> This will make it easier to use multiple configs, e.g. for different
> boards.
>
> Signed-off-by: Alyssa Ross <hi@alyssa.is>
>

Tested-by: José Pekkarinen <jose.pekkarinen@unikie.com>


> ---
>  nix/eval-config.nix | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/nix/eval-config.nix b/nix/eval-config.nix
> index 9265df7..467f877 100644
> --- a/nix/eval-config.nix
> +++ b/nix/eval-config.nix
> @@ -2,7 +2,10 @@
>  # SPDX-FileCopyrightText: 2022 Unikie
>
>  { config ?
> -  if builtins.pathExists ../config.nix then import ../config.nix else {}
> +  let customPath = builtins.tryEval <spectrum-config>; in
> +  if customPath.success then import customPath.value
> +  else if builtins.pathExists ../config.nix then import ../config.nix
> +  else {}
>  }:
>
>  ({ pkgs ? import <nixpkgs> {} }: {
> --
> 2.37.1
>
>

-- 

José.

[-- Attachment #2: Type: text/html, Size: 1823 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] Introduce a build configuration file
  2022-08-31  9:37 [PATCH 1/4] Introduce a build configuration file Alyssa Ross
                   ` (3 preceding siblings ...)
  2022-09-06  5:53 ` [PATCH 1/4] Introduce a " Ville Ilvonen
@ 2022-09-14  6:58 ` Alyssa Ross
  4 siblings, 0 replies; 11+ messages in thread
From: Alyssa Ross @ 2022-09-14  6:58 UTC (permalink / raw)
  To: Alyssa Ross, devel; +Cc: José Pekkarinen, Ivan Nikolaenko

This patch has been committed as b508c467d0a54f1aa60c138acdc6677a8ba77abd,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=b508c467d0a54f1aa60c138acdc6677a8ba77abd.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] nix: prefer build configs from <spectrum-config>
  2022-08-31  9:37 ` [PATCH 2/4] nix: prefer build configs from <spectrum-config> Alyssa Ross
  2022-09-08 11:40   ` José Pekkarinen
@ 2022-09-14  6:58   ` Alyssa Ross
  1 sibling, 0 replies; 11+ messages in thread
From: Alyssa Ross @ 2022-09-14  6:58 UTC (permalink / raw)
  To: Alyssa Ross, devel; +Cc: José Pekkarinen, Ivan Nikolaenko

This patch has been committed as b95488e501cbd26475eb27ea01840245283e9972,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=b95488e501cbd26475eb27ea01840245283e9972.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] Documentation: document build configuration file
  2022-08-31  9:37 ` [PATCH 4/4] Documentation: document build configuration file Alyssa Ross
@ 2022-09-14  6:58   ` Alyssa Ross
  0 siblings, 0 replies; 11+ messages in thread
From: Alyssa Ross @ 2022-09-14  6:58 UTC (permalink / raw)
  To: Alyssa Ross, devel
  Cc: José Pekkarinen, Ivan Nikolaenko, Evgeniia Nikolaenko

This patch has been committed as eb2b4c7c89881eb622412ca2d87e9606f5940a30,
which can be viewed online at
https://spectrum-os.org/git/spectrum/commit/?id=eb2b4c7c89881eb622412ca2d87e9606f5940a30.

This is an automated message.  Send comments/questions/requests to:
Alyssa Ross <hi@alyssa.is>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] Documentation/jekyll: patch for AsciiDoc examples
  2022-08-31  9:37 ` [PATCH 3/4] Documentation/jekyll: patch for AsciiDoc examples Alyssa Ross
@ 2022-09-14  7:03   ` Alyssa Ross
  0 siblings, 0 replies; 11+ messages in thread
From: Alyssa Ross @ 2022-09-14  7:03 UTC (permalink / raw)
  To: devel; +Cc: José Pekkarinen, Ivan Nikolaenko

[-- Attachment #1: Type: text/plain, Size: 763 bytes --]

Alyssa Ross <hi@alyssa.is> writes:

> The documentation I would like to add for the build configuration file
> uses a titled example, which doesn't render nicely with Just The Docs
> without this change.
>
> Signed-off-by: Alyssa Ross <hi@alyssa.is>
> ---
>  Documentation/jekyll.nix | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)

I ended up pushing a different patch for this[1].  Just the Docs
accepted my PR[2] and then released it in a release candidate shortly
after, so all I had to do was update to that release candidate, rather
than patching Just the Docs.

[1]: https://spectrum-os.org/git/spectrum/commit/?id=b432093ec12c5d2274c3d6958f62e56c0a32bc75
[2]: https://github.com/just-the-docs/just-the-docs/pull/944

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-14  7:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  9:37 [PATCH 1/4] Introduce a build configuration file Alyssa Ross
2022-08-31  9:37 ` [PATCH 2/4] nix: prefer build configs from <spectrum-config> Alyssa Ross
2022-09-08 11:40   ` José Pekkarinen
2022-09-14  6:58   ` Alyssa Ross
2022-08-31  9:37 ` [PATCH 3/4] Documentation/jekyll: patch for AsciiDoc examples Alyssa Ross
2022-09-14  7:03   ` Alyssa Ross
2022-08-31  9:37 ` [PATCH 4/4] Documentation: document build configuration file Alyssa Ross
2022-09-14  6:58   ` Alyssa Ross
2022-09-06  5:53 ` [PATCH 1/4] Introduce a " Ville Ilvonen
     [not found]   ` <87fsh5c60x.fsf@alyssa.is>
2022-09-08 11:39     ` José Pekkarinen
2022-09-14  6:58 ` Alyssa Ross

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

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

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).