patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Spectrum OS Development <devel@spectrum-os.org>
Cc: Alyssa Ross <hi@alyssa.is>, Demi Marie Obenour <demiobenour@gmail.com>
Subject: [PATCH] Prefer definition-before-use in Nix
Date: Mon, 08 Sep 2025 23:45:16 -0400	[thread overview]
Message-ID: <20250908-nix-cleanup-v1-1-1a0e49e5ec4e@gmail.com> (raw)

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)


             reply	other threads:[~2025-09-09  3:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09  3:45 Demi Marie Obenour [this message]
2025-09-09 14:54 ` [PATCH] Prefer definition-before-use in Nix Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250908-nix-cleanup-v1-1-1a0e49e5ec4e@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).