From 9a65ff8c87d8160384d9558769108eced531f0af Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 22 Feb 2023 16:27:38 +0000 Subject: nix/eval-config.nix: fix custom configuration When I introduced the global src attribute, I broke custom configurations, since they wouldn't be passing that key in, and nor should they. To allow for non-customisable globals like src, we need to separate them from config. Here, I've modified eval-config.nix to take a callback, so that it can provide multiple attributes, and handle command line arguments itself so that doesn't need to be in every entry point any more. This gives us an interface similar to the NixOS module system's, where a variety of globals are available that can be pulled out of the passed attribute set as required, but with the additional advantage that files are usable directly from nix-build, and support command line arguments. Signed-off-by: Alyssa Ross Fixes: 0149885 ("nix: centralise source cleaning") --- release/combined/default.nix | 4 ++-- release/combined/eosimages.nix | 4 ++-- release/combined/run-vm.nix | 4 ++-- release/installer/default.nix | 5 ++--- release/installer/run-vm.nix | 4 ++-- release/live/default.nix | 7 ++++--- release/live/shell.nix | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'release') diff --git a/release/combined/default.nix b/release/combined/default.nix index 2865376..7f7b3a2 100644 --- a/release/combined/default.nix +++ b/release/combined/default.nix @@ -3,7 +3,7 @@ # SPDX-FileCopyrightText: 2021 Yureka # SPDX-FileCopyrightText: 2022 Unikie -{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs; +import ../../nix/eval-config.nix ({ config, ... } @ args: with config.pkgs; let inherit (builtins) storeDir; @@ -113,4 +113,4 @@ runCommand "spectrum-installer" { fillPartition $out 0 ${esp} fillPartition $out 1 ${rootfs} fillPartition $out 2 ${eosimages} -'' +'') diff --git a/release/combined/eosimages.nix b/release/combined/eosimages.nix index 9f2ab10..b2dba13 100644 --- a/release/combined/eosimages.nix +++ b/release/combined/eosimages.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross -{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs; +import ../../nix/eval-config.nix ({ config, ... }: with config.pkgs; runCommand "eosimages.img" { nativeBuildInputs = [ e2fsprogs tar2ext4 ]; @@ -15,4 +15,4 @@ runCommand "eosimages.img" { tar -chf $NIX_BUILD_TOP/eosimages.tar * tar2ext4 -i $NIX_BUILD_TOP/eosimages.tar -o $out e2label $out eosimages -'' +'') diff --git a/release/combined/run-vm.nix b/release/combined/run-vm.nix index 2fc474e..10bd8bf 100644 --- a/release/combined/run-vm.nix +++ b/release/combined/run-vm.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021 Alyssa Ross -{ config ? import ../../nix/eval-config.nix {} }: with config.pkgs; +import ../../nix/eval-config.nix ({ config, ... }: with config.pkgs; let image = import ./. { inherit config; }; @@ -22,4 +22,4 @@ writeShellScript "run-spectrum-installer-vm.sh" '' -drive file=${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd,format=raw,if=pflash,readonly=true \ -drive file=${image},id=drive1,format=raw,if=none,readonly=true \ -drive file=/proc/self/fd/3,format=raw,if=virtio -'' +'') diff --git a/release/installer/default.nix b/release/installer/default.nix index 0c57704..16a7d35 100644 --- a/release/installer/default.nix +++ b/release/installer/default.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross -{ config ? import ../../nix/eval-config.nix {}, extraConfig ? {} }: +import ../../nix/eval-config.nix ({ config, extraConfig ? {}, ... }: with config.pkgs; let @@ -21,5 +21,4 @@ in ] ++ config.boot.kernelParams); store = writeReferencesToFile config.system.build.toplevel; -} - +}) diff --git a/release/installer/run-vm.nix b/release/installer/run-vm.nix index fe014f8..c42155b 100644 --- a/release/installer/run-vm.nix +++ b/release/installer/run-vm.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross -{ config ? import ../../nix/eval-config.nix {} }: +import ../../nix/eval-config.nix ({ config, ... }: let inherit (builtins) storeDir; @@ -43,4 +43,4 @@ writeShellScript "run-spectrum-installer-vm.sh" '' -kernel ${installer.kernel} \ -initrd ${installer.initramfs} \ -append ${escapeShellArg installer.kernelParams} -'' +'') diff --git a/release/live/default.nix b/release/live/default.nix index 66bba26..c36c34b 100644 --- a/release/live/default.nix +++ b/release/live/default.nix @@ -2,7 +2,8 @@ # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross # SPDX-FileCopyrightText: 2022 Unikie -{ config ? import ../../nix/eval-config.nix {} }: config.pkgs.callPackage ( +import ../../nix/eval-config.nix ({ config, src, ... }: +config.pkgs.callPackage ( { stdenvNoCC, cryptsetup, dosfstools, jq, mtools, util-linux, stdenv , systemd }: @@ -22,7 +23,7 @@ in stdenvNoCC.mkDerivation { name = "spectrum-live.img"; - inherit (config) src; + inherit src; sourceRoot = "source/release/live"; nativeBuildInputs = [ cryptsetup dosfstools jq mtools util-linux ]; @@ -46,4 +47,4 @@ stdenvNoCC.mkDerivation { passthru = { inherit rootfs; }; } -) {} +) {}) diff --git a/release/live/shell.nix b/release/live/shell.nix index dcf2059..7cec144 100644 --- a/release/live/shell.nix +++ b/release/live/shell.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross -{ config ? import ../../nix/eval-config.nix {} }: +import ../../nix/eval-config.nix ({ config, ... }: with config.pkgs; @@ -12,4 +12,4 @@ with config.pkgs; OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd"; } -) +)) -- cgit 1.4.1