* [PATCH] Prefer definition-before-use in Nix
@ 2025-09-09 3:45 Demi Marie Obenour
2025-09-09 14:54 ` Alyssa Ross
0 siblings, 1 reply; 2+ messages in thread
From: Demi Marie Obenour @ 2025-09-09 3:45 UTC (permalink / raw)
To: Spectrum OS Development; +Cc: Alyssa Ross, Demi Marie Obenour
Nix does not require this, but it is easier to read.
No functional change intended.
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
img/app/default.nix | 74 ++++++++++++++++++++++++--------------------------
vm/sys/net/default.nix | 72 ++++++++++++++++++++++++------------------------
2 files changed, 72 insertions(+), 74 deletions(-)
diff --git a/img/app/default.nix b/img/app/default.nix
index d3eed1f0accdc8968d1ba5bdec74ab597789082f..71a939c1c053ebd37fc02fa4eed49b883d50ef49 100644
--- a/img/app/default.nix
+++ b/img/app/default.nix
@@ -12,6 +12,42 @@ pkgsStatic.callPackage (
}:
let
+ kernelTarget =
+ if stdenvNoCC.hostPlatform.isx86 then
+ # vmlinux.bin is the stripped version of vmlinux.
+ # Confusingly, compressed/vmlinux.bin is the stripped version of
+ # the top-level vmlinux target, while the top-level vmlinux.bin
+ # is the stripped version of compressed/vmlinux. So we use
+ # compressed/vmlinux.bin, since we want a stripped version of
+ # the kernel that *hasn't* been built to be compressed. Weird!
+ "compressed/vmlinux.bin"
+ else
+ stdenvNoCC.hostPlatform.linux-kernel.target;
+
+ kernel = (linux_latest.override {
+ structuredExtraConfig = with lib.kernel; {
+ DRM_FBDEV_EMULATION = lib.mkForce no;
+ EROFS_FS = yes;
+ FONTS = lib.mkForce unset;
+ FONT_8x8 = lib.mkForce unset;
+ FONT_TER16x32 = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE_DETECT_PRIMARY = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE_ROTATION = lib.mkForce unset;
+ RC_CORE = lib.mkForce unset;
+ VIRTIO = yes;
+ VIRTIO_BLK = yes;
+ VIRTIO_CONSOLE = yes;
+ VIRTIO_PCI = yes;
+ VT = no;
+ };
+ }).overrideAttrs ({ installFlags ? [], ... }: {
+ installFlags = installFlags ++ [
+ "KBUILD_IMAGE=$(boot)/${kernelTarget}"
+ ];
+ });
+
appimageFhsenv = (buildFHSEnv (appimageTools.defaultFhsEnvArgs // {
name = "vm-fhs-env";
targetPkgs = pkgs: appimageTools.defaultFhsEnvArgs.targetPkgs pkgs ++ [
@@ -53,50 +89,12 @@ let
pkgs.wireplumber
];
})).fhsenv;
-in
-let
packagesSysroot = runCommand "packages-sysroot" {} ''
mkdir -p $out/etc/ssl/certs
ln -s ${appimageFhsenv}/{lib64,usr} ${kernel}/lib $out
ln -s ${cacert}/etc/ssl/certs/* $out/etc/ssl/certs
'';
-
- kernelTarget =
- if stdenvNoCC.hostPlatform.isx86 then
- # vmlinux.bin is the stripped version of vmlinux.
- # Confusingly, compressed/vmlinux.bin is the stripped version of
- # the top-level vmlinux target, while the top-level vmlinux.bin
- # is the stripped version of compressed/vmlinux. So we use
- # compressed/vmlinux.bin, since we want a stripped version of
- # the kernel that *hasn't* been built to be compressed. Weird!
- "compressed/vmlinux.bin"
- else
- stdenvNoCC.hostPlatform.linux-kernel.target;
-
- kernel = (linux_latest.override {
- structuredExtraConfig = with lib.kernel; {
- DRM_FBDEV_EMULATION = lib.mkForce no;
- EROFS_FS = yes;
- FONTS = lib.mkForce unset;
- FONT_8x8 = lib.mkForce unset;
- FONT_TER16x32 = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE_DETECT_PRIMARY = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE_ROTATION = lib.mkForce unset;
- RC_CORE = lib.mkForce unset;
- VIRTIO = yes;
- VIRTIO_BLK = yes;
- VIRTIO_CONSOLE = yes;
- VIRTIO_PCI = yes;
- VT = no;
- };
- }).overrideAttrs ({ installFlags ? [], ... }: {
- installFlags = installFlags ++ [
- "KBUILD_IMAGE=$(boot)/${kernelTarget}"
- ];
- });
in
stdenvNoCC.mkDerivation {
diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix
index b5873ebe1e80dd88c1ba997f7ebd3ee7369bb40f..7b2b8b1fbb9b9027781812307bed0551b80f5a78 100644
--- a/vm/sys/net/default.nix
+++ b/vm/sys/net/default.nix
@@ -14,6 +14,42 @@ let
inherit (lib) concatMapStringsSep;
inherit (nixosAllHardware.config.hardware) firmware;
+ kernelTarget =
+ if stdenvNoCC.hostPlatform.isx86 then
+ # vmlinux.bin is the stripped version of vmlinux.
+ # Confusingly, compressed/vmlinux.bin is the stripped version of
+ # the top-level vmlinux target, while the top-level vmlinux.bin
+ # is the stripped version of compressed/vmlinux. So we use
+ # compressed/vmlinux.bin, since we want a stripped version of
+ # the kernel that *hasn't* been built to be compressed. Weird!
+ "compressed/vmlinux.bin"
+ else
+ stdenvNoCC.hostPlatform.linux-kernel.target;
+
+ kernel = (linux_latest.override {
+ structuredExtraConfig = with lib.kernel; {
+ DRM_FBDEV_EMULATION = lib.mkForce no;
+ EROFS_FS = yes;
+ FONTS = lib.mkForce unset;
+ FONT_8x8 = lib.mkForce unset;
+ FONT_TER16x32 = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE_DETECT_PRIMARY = lib.mkForce unset;
+ FRAMEBUFFER_CONSOLE_ROTATION = lib.mkForce unset;
+ RC_CORE = lib.mkForce unset;
+ VIRTIO = yes;
+ VIRTIO_BLK = yes;
+ VIRTIO_CONSOLE = yes;
+ VIRTIO_PCI = yes;
+ VT = no;
+ };
+ }).overrideAttrs ({ installFlags ? [], ... }: {
+ installFlags = installFlags ++ [
+ "KBUILD_IMAGE=$(boot)/${kernelTarget}"
+ ];
+ });
+
connman = connmanMinimal;
packages = [
@@ -58,42 +94,6 @@ let
system.stateVersion = lib.trivial.release;
});
-
- kernelTarget =
- if stdenvNoCC.hostPlatform.isx86 then
- # vmlinux.bin is the stripped version of vmlinux.
- # Confusingly, compressed/vmlinux.bin is the stripped version of
- # the top-level vmlinux target, while the top-level vmlinux.bin
- # is the stripped version of compressed/vmlinux. So we use
- # compressed/vmlinux.bin, since we want a stripped version of
- # the kernel that *hasn't* been built to be compressed. Weird!
- "compressed/vmlinux.bin"
- else
- stdenvNoCC.hostPlatform.linux-kernel.target;
-
- kernel = (linux_latest.override {
- structuredExtraConfig = with lib.kernel; {
- DRM_FBDEV_EMULATION = lib.mkForce no;
- EROFS_FS = yes;
- FONTS = lib.mkForce unset;
- FONT_8x8 = lib.mkForce unset;
- FONT_TER16x32 = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE_DETECT_PRIMARY = lib.mkForce unset;
- FRAMEBUFFER_CONSOLE_ROTATION = lib.mkForce unset;
- RC_CORE = lib.mkForce unset;
- VIRTIO = yes;
- VIRTIO_BLK = yes;
- VIRTIO_CONSOLE = yes;
- VIRTIO_PCI = yes;
- VT = no;
- };
- }).overrideAttrs ({ installFlags ? [], ... }: {
- installFlags = installFlags ++ [
- "KBUILD_IMAGE=$(boot)/${kernelTarget}"
- ];
- });
in
stdenvNoCC.mkDerivation {
---
base-commit: 8ce6039b6dde7fda98ceea018addecb8bee0e7b3
change-id: 20250908-nix-cleanup-8496862dfee9
--
Sincerely,
Demi Marie Obenour (she/her/hers)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-09 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09 3:45 [PATCH] Prefer definition-before-use in Nix Demi Marie Obenour
2025-09-09 14:54 ` 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).