mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0fe8a3b4b |
No files matched your search
+4
-29
@@ -198,24 +198,10 @@ main() {
|
|||||||
flakeAttr="${BASH_REMATCH[2]}"
|
flakeAttr="${BASH_REMATCH[2]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Resolve flake to nix store path to respect git tracking
|
if [[ -e "$flake" ]]; then
|
||||||
if ! flake_metadata=$(nix flake metadata --json "${nix_args[@]}" "$flake" 2>&1); then
|
flake=$(realpath "$flake")
|
||||||
echo "Failed to resolve flake metadata for: $flake" >&2
|
|
||||||
echo "$flake_metadata" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract the "path" field from JSON using sed
|
|
||||||
flake_path=$(echo "$flake_metadata" | sed -nE 's/.*"path": ?"([^"]+)".*/\1/p')
|
|
||||||
|
|
||||||
if [[ -z "$flake_path" ]]; then
|
|
||||||
echo "Failed to get store path from flake metadata" >&2
|
|
||||||
echo "$flake_metadata" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
flake="$flake_path"
|
|
||||||
|
|
||||||
if [[ -z ${flakeAttr-} ]]; then
|
if [[ -z ${flakeAttr-} ]]; then
|
||||||
echo "Please specify the name of the NixOS configuration to be installed, as a URI fragment in the flake-uri." >&2
|
echo "Please specify the name of the NixOS configuration to be installed, as a URI fragment in the flake-uri." >&2
|
||||||
echo 'For example, to use the output nixosConfigurations.foo from the flake.nix, append "#foo" to the flake-uri.' >&2
|
echo 'For example, to use the output nixosConfigurations.foo from the flake.nix, append "#foo" to the flake-uri.' >&2
|
||||||
@@ -229,7 +215,7 @@ main() {
|
|||||||
trap cleanupMountPoint EXIT
|
trap cleanupMountPoint EXIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \
|
outputs=$(nixBuild "${libexec_dir}"/install-cli.nix \
|
||||||
"${nix_args[@]}" \
|
"${nix_args[@]}" \
|
||||||
--no-out-link \
|
--no-out-link \
|
||||||
--impure \
|
--impure \
|
||||||
@@ -241,20 +227,9 @@ main() {
|
|||||||
--argstr extraSystemConfig "$extraSystemConfig" \
|
--argstr extraSystemConfig "$extraSystemConfig" \
|
||||||
-A installToplevel \
|
-A installToplevel \
|
||||||
-A closureInfo \
|
-A closureInfo \
|
||||||
-A "$diskoAttr"); then
|
-A "$diskoAttr")
|
||||||
echo "Failed to build NixOS configuration" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
IFS=$'\n' mapfile -t artifacts <<<"$outputs"
|
IFS=$'\n' mapfile -t artifacts <<<"$outputs"
|
||||||
|
|
||||||
if [[ ${#artifacts[@]} -ne 3 ]]; then
|
|
||||||
echo "Expected 3 build outputs, got ${#artifacts[@]}" >&2
|
|
||||||
echo "Outputs received:" >&2
|
|
||||||
printf '%s\n' "${artifacts[@]}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
nixos_system=${artifacts[0]}
|
nixos_system=${artifacts[0]}
|
||||||
closure_info=${artifacts[1]}
|
closure_info=${artifacts[1]}
|
||||||
disko_script=${artifacts[2]}
|
disko_script=${artifacts[2]}
|
||||||
|
|||||||
@@ -82,6 +82,6 @@ in
|
|||||||
-F qcow2 "$tmp"/${lib.escapeShellArg disk.imageName}.qcow2
|
-F qcow2 "$tmp"/${lib.escapeShellArg disk.imageName}.qcow2
|
||||||
'') disks}
|
'') disks}
|
||||||
set +f
|
set +f
|
||||||
${config.system.build.vm}/bin/run-*-vm "$@"
|
${config.system.build.vm}/bin/run-*-vm
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,6 @@ let
|
|||||||
checked = diskoCfg.checkScripts;
|
checked = diskoCfg.checkScripts;
|
||||||
|
|
||||||
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
configSupportsZfs = config.boot.supportedFilesystems.zfs or false;
|
||||||
configSupportsBcachefs = config.boot.supportedFilesystems.bcachefs or false;
|
|
||||||
binfmt = diskoLib.binfmt {
|
binfmt = diskoLib.binfmt {
|
||||||
inherit
|
inherit
|
||||||
diskoLib
|
diskoLib
|
||||||
@@ -42,7 +41,6 @@ let
|
|||||||
"virtio_rng"
|
"virtio_rng"
|
||||||
]
|
]
|
||||||
++ (lib.optional configSupportsZfs "zfs")
|
++ (lib.optional configSupportsZfs "zfs")
|
||||||
++ (lib.optional configSupportsBcachefs "bcachefs")
|
|
||||||
++ cfg.extraRootModules;
|
++ cfg.extraRootModules;
|
||||||
kernel = pkgs.aggregateModules (
|
kernel = pkgs.aggregateModules (
|
||||||
[
|
[
|
||||||
@@ -52,10 +50,6 @@ let
|
|||||||
++ lib.optional (
|
++ lib.optional (
|
||||||
lib.elem "zfs" cfg.extraRootModules || configSupportsZfs
|
lib.elem "zfs" cfg.extraRootModules || configSupportsZfs
|
||||||
) cfg.kernelPackages.${config.boot.zfs.package.kernelModuleAttribute}
|
) cfg.kernelPackages.${config.boot.zfs.package.kernelModuleAttribute}
|
||||||
++ lib.optional (
|
|
||||||
(lib.elem "bcachefs" cfg.extraRootModules || configSupportsBcachefs)
|
|
||||||
&& pkgs.bcachefs-tools ? kernelModule
|
|
||||||
) (cfg.kernelPackages.callPackage pkgs.bcachefs-tools.kernelModule { })
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu lib) {
|
// lib.optionalAttrs (diskoLib.vmToolsSupportsCustomQemu lib) {
|
||||||
@@ -82,7 +76,6 @@ let
|
|||||||
disko.testMode = true;
|
disko.testMode = true;
|
||||||
disko.devices = lib.mkForce cleanedConfig.disko.devices;
|
disko.devices = lib.mkForce cleanedConfig.disko.devices;
|
||||||
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
|
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
|
||||||
boot.kernelPackages = cfg.kernelPackages;
|
|
||||||
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-8
@@ -89,7 +89,7 @@ let
|
|||||||
args:
|
args:
|
||||||
makeTest args {
|
makeTest args {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
system = pkgs.stdenv.hostPlatform.system;
|
inherit (pkgs) system;
|
||||||
};
|
};
|
||||||
# for installation we skip /dev/vda because it is the test runner disk
|
# for installation we skip /dev/vda because it is the test runner disk
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ let
|
|||||||
|
|
||||||
installed-system-eval = eval-config {
|
installed-system-eval = eval-config {
|
||||||
modules = [ installed-system ];
|
modules = [ installed-system ];
|
||||||
system = pkgs.stdenv.hostPlatform.system;
|
inherit (pkgs) system;
|
||||||
};
|
};
|
||||||
|
|
||||||
installedTopLevel =
|
installedTopLevel =
|
||||||
@@ -181,9 +181,6 @@ let
|
|||||||
};
|
};
|
||||||
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
|
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
|
||||||
|
|
||||||
# Silence mdadm warning about missing MAILADDR or PROGRAM
|
|
||||||
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
|
||||||
|
|
||||||
# grub will install to these devices, we need to force those or we are offset by 1
|
# grub will install to these devices, we need to force those or we are offset by 1
|
||||||
# we use mkOveride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
|
# we use mkOveride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
|
||||||
boot.loader.grub.devices = lib.mkOverride 70 testConfigInstall.boot.loader.grub.devices;
|
boot.loader.grub.devices = lib.mkOverride 70 testConfigInstall.boot.loader.grub.devices;
|
||||||
@@ -251,10 +248,7 @@ let
|
|||||||
(
|
(
|
||||||
if lib.versionAtLeast (lib.versions.majorMinor lib.version) "23.11" then
|
if lib.versionAtLeast (lib.versions.majorMinor lib.version) "23.11" then
|
||||||
{
|
{
|
||||||
# From https://github.com/NixOS/nixpkgs/blob/7a8665e3a624a01b10d10d10b819cb1a8f34ee6e/nixos/modules/profiles/installation-device.nix#L116-L118
|
|
||||||
boot.swraid.enable = true;
|
boot.swraid.enable = true;
|
||||||
# remove warning about unset mail
|
|
||||||
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -229,8 +229,6 @@ in
|
|||||||
''}
|
''}
|
||||||
${lib.optionalString hp.config.mbrBootableFlag ''
|
${lib.optionalString hp.config.mbrBootableFlag ''
|
||||||
sfdisk --label-nested dos --activate "${parent.device}" ${(toString partition.config._index)}
|
sfdisk --label-nested dos --activate "${parent.device}" ${(toString partition.config._index)}
|
||||||
udevadm trigger --subsystem-match=block
|
|
||||||
udevadm settle --timeout 120
|
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user