From 8353a681b5d6416b4c610dd54f1a176c554ead9b Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 19 Sep 2024 20:07:14 +0300 Subject: [PATCH] nixos-build-vms: move to pkgs/by-name --- nixos/modules/installer/tools/tools.nix | 7 +----- .../by-name/ni}/nixos-build-vms/build-vms.nix | 5 +++-- .../ni/nixos-build-vms}/nixos-build-vms.8 | 0 .../ni}/nixos-build-vms/nixos-build-vms.sh | 5 +++-- pkgs/by-name/ni/nixos-build-vms/package.nix | 22 +++++++++++++++++++ 5 files changed, 29 insertions(+), 10 deletions(-) rename {nixos/modules/installer/tools => pkgs/by-name/ni}/nixos-build-vms/build-vms.nix (87%) rename {nixos/modules/installer/tools/manpages => pkgs/by-name/ni/nixos-build-vms}/nixos-build-vms.8 (100%) rename {nixos/modules/installer/tools => pkgs/by-name/ni}/nixos-build-vms/nixos-build-vms.sh (86%) create mode 100644 pkgs/by-name/ni/nixos-build-vms/package.nix diff --git a/nixos/modules/installer/tools/tools.nix b/nixos/modules/installer/tools/tools.nix index 7f16b97440c1..3d227eebc2d3 100644 --- a/nixos/modules/installer/tools/tools.nix +++ b/nixos/modules/installer/tools/tools.nix @@ -17,12 +17,7 @@ let ''; }); - nixos-build-vms = makeProg { - name = "nixos-build-vms"; - src = ./nixos-build-vms/nixos-build-vms.sh; - inherit (pkgs) runtimeShell; - manPage = ./manpages/nixos-build-vms.8; - }; + inherit (pkgs) nixos-build-vms; nixos-install = makeProg { name = "nixos-install"; diff --git a/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix b/pkgs/by-name/ni/nixos-build-vms/build-vms.nix similarity index 87% rename from nixos/modules/installer/tools/nixos-build-vms/build-vms.nix rename to pkgs/by-name/ni/nixos-build-vms/build-vms.nix index 21a257378a63..12b3c44746a4 100644 --- a/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix +++ b/pkgs/by-name/ni/nixos-build-vms/build-vms.nix @@ -1,5 +1,6 @@ { system ? builtins.currentSystem , config ? {} +, nixpkgs , networkExpr }: @@ -9,9 +10,9 @@ let imports = [ module ]; }) (import networkExpr); - pkgs = import ../../../../.. { inherit system config; }; + pkgs = import nixpkgs { inherit system config; }; - testing = import ../../../../lib/testing-python.nix { + testing = import "${pkgs.path}/nixos/lib/testing-python.nix" { inherit system pkgs; }; diff --git a/nixos/modules/installer/tools/manpages/nixos-build-vms.8 b/pkgs/by-name/ni/nixos-build-vms/nixos-build-vms.8 similarity index 100% rename from nixos/modules/installer/tools/manpages/nixos-build-vms.8 rename to pkgs/by-name/ni/nixos-build-vms/nixos-build-vms.8 diff --git a/nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh b/pkgs/by-name/ni/nixos-build-vms/nixos-build-vms.sh similarity index 86% rename from nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh rename to pkgs/by-name/ni/nixos-build-vms/nixos-build-vms.sh index 490ede04e6bb..d55eb5d0620f 100644 --- a/nixos/modules/installer/tools/nixos-build-vms/nixos-build-vms.sh +++ b/pkgs/by-name/ni/nixos-build-vms/nixos-build-vms.sh @@ -49,5 +49,6 @@ then fi # Build a network of VMs -nix-build '' \ - --argstr networkExpr "$networkExpr" "${nixBuildArgs[@]}" +nix-build @buildVms@ \ + --argstr networkExpr "$networkExpr" "${nixBuildArgs[@]}" \ + --arg nixpkgs "" diff --git a/pkgs/by-name/ni/nixos-build-vms/package.nix b/pkgs/by-name/ni/nixos-build-vms/package.nix new file mode 100644 index 000000000000..fc8b4f403e94 --- /dev/null +++ b/pkgs/by-name/ni/nixos-build-vms/package.nix @@ -0,0 +1,22 @@ +{ + substituteAll, + runtimeShell, + installShellFiles, +}: +substituteAll { + name = "nixos-build-vms"; + src = ./nixos-build-vms.sh; + inherit runtimeShell; + buildVms = ./build-vms.nix; + + dir = "bin"; + isExecutable = true; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = '' + installManPage ${./nixos-build-vms.8} + ''; + + meta.mainProgram = "nixos-build-vms"; +}