From 6c3e0d22e465541b35772ba4a00331f587bc28c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 29 Nov 2022 10:53:56 +0100 Subject: remove dependency on bash --- module.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module.nix b/module.nix index 0655880..47c52dd 100644 --- a/module.nix +++ b/module.nix @@ -52,7 +52,8 @@ in { ''; # This is useful to skip copying executables uploading a script to an in-memory installer - system.build.diskoNoDeps = pkgs.writers.writeBash "disko" '' + system.build.diskoNoDeps = pkgs.writeScript "disko" '' + #!/usr/bin/env bash ${types.diskoLib.zapCreateMount cfg.devices} ''; -- cgit v1.2.3 From 67f991e2bcf38d7c2a99f1cdbbdb4fbc60b8e8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 29 Nov 2022 14:58:31 +0100 Subject: drop environment.systemPackages Those packages are only used for installation and are not used afterwards. system.build outputs can be used to get them in an installer included. --- module.nix | 18 ------------------ tests/lib.nix | 2 -- 2 files changed, 20 deletions(-) diff --git a/module.nix b/module.nix index 47c52dd..9b568be 100644 --- a/module.nix +++ b/module.nix @@ -16,26 +16,8 @@ in { type = lib.types.bool; default = true; }; - addScripts = lib.mkOption { - description = '' - add disko-create and disko-mount scripts to systemPackages. - ''; - type = lib.types.bool; - default = true; - }; }; config = { - environment.systemPackages = (lib.optionals cfg.addScripts [ - (pkgs.writers.writeDashBin "disko-create" '' - export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)} - ${types.diskoLib.create cfg.devices} - '') - (pkgs.writers.writeDashBin "disko-mount" '' - export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)} - ${types.diskoLib.mount cfg.devices} - '') - ]) ++ lib.optionals cfg.enableConfig (types.diskoLib.packages cfg.devices pkgs); - system.build.formatScript = pkgs.writers.writeDash "disko-create" '' export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)} ${types.diskoLib.create cfg.devices} diff --git a/tests/lib.nix b/tests/lib.nix index 195abcc..3fb3486 100644 --- a/tests/lib.nix +++ b/tests/lib.nix @@ -33,7 +33,6 @@ (lib.optionalAttrs (testMode == "module") { imports = [ ../module.nix ]; disko = { - addScripts = false; enableConfig = true; devices = import disko-config { inherit disks lib; }; }; @@ -76,7 +75,6 @@ (lib.optionalAttrs (testMode == "module") { imports = [ ../module.nix ]; disko = { - addScripts = true; enableConfig = false; devices = import disko-config { disks = builtins.tail disks; inherit lib; }; }; -- cgit v1.2.3 From 0d922a482d78c62585d4215e58312a2b86da09b1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 1 Dec 2022 20:10:21 +0100 Subject: flake: fix style --- flake.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index dd065cf..c2039b7 100644 --- a/flake.nix +++ b/flake.nix @@ -25,12 +25,12 @@ passAsFile = ["buildPhase"]; buildPhase = '' mkdir -p $out/bin $out/share/disko - cp -r $src/* $out/share/disko - sed \ - -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" \ - -e "s|#!/usr/bin/env.*|#!/usr/bin/env bash|" \ - $src/disko > $out/bin/disko - chmod 755 $out/bin/disko + cp -r $src/* $out/share/disko + sed \ + -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" \ + -e "s|#!/usr/bin/env.*|#!/usr/bin/env bash|" \ + $src/disko > $out/bin/disko + chmod 755 $out/bin/disko ''; args = ["-c" ". $buildPhasePath"]; src = inclFiles { inherit name; src = ./.; } [ -- cgit v1.2.3 From c3a7680451b25214ddbee3ab55a6d1b67f6e2a60 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 1 Dec 2022 20:10:58 +0100 Subject: example with-lib: remove traceValSeq --- example/with-lib.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/with-lib.nix b/example/with-lib.nix index e746f5b..ce0b93d 100644 --- a/example/with-lib.nix +++ b/example/with-lib.nix @@ -1,6 +1,6 @@ # Example to create a bios compatible gpt partition { disks ? [ "/dev/vdb" ], lib, ... }: { - disk = lib.traceValSeq (lib.genAttrs [ (lib.head disks) ] (device: { + disk = lib.genAttrs [ (lib.head disks) ] (device: { device = device; type = "disk"; content = { @@ -31,5 +31,5 @@ } ]; }; - })); + }); } -- cgit v1.2.3 From 0f21bc31fe237ed1c9f8fdd3a0e8be633588302a Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 1 Dec 2022 20:11:22 +0100 Subject: tests module: test system.build output instead of systemPackages --- tests/lib.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/lib.nix b/tests/lib.nix index 3fb3486..6d787ed 100644 --- a/tests/lib.nix +++ b/tests/lib.nix @@ -103,7 +103,7 @@ virtualisation.emptyDiskImages = builtins.genList (_: 4096) num-disks; }; - testScript = '' + testScript = { nodes, ... }: '' def disks(oldmachine, num_disks): disk_flags = "" for i in range(num_disks): @@ -126,9 +126,9 @@ machine.succeed("${tsp-mount}") # verify that the command is idempotent ''} ${lib.optionalString (testMode == "module") '' - machine.succeed("disko-create") - machine.succeed("disko-mount") - machine.succeed("disko-mount") # verify that the command is idempotent + machine.succeed("${nodes.machine.system.build.formatScript}") + machine.succeed("${nodes.machine.system.build.mountScript}") + machine.succeed("${nodes.machine.system.build.mountScript}") # verify that the command is idempotent ''} ${lib.optionalString (testMode == "cli") '' # TODO use the disko cli here -- cgit v1.2.3 From 25cc022282590f36ed2c3cb542774053d58dddc8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 1 Dec 2022 20:33:03 +0100 Subject: disko cli: add --no-deps mode --- cli.nix | 25 ++++++++++++++++++------- default.nix | 18 +++++++++++++++++- disko | 3 +++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/cli.nix b/cli.nix index 72a1c3c..3295346 100644 --- a/cli.nix +++ b/cli.nix @@ -3,6 +3,7 @@ , flake ? null , flakeAttr ? null , diskoFile ? null +, noDeps ? false , ... }@args: let disko = import ./. { }; @@ -12,13 +13,23 @@ let else import diskoFile args; - diskoEval = if (mode == "create") then - disko.createScript diskFormat pkgs - else if (mode == "mount") then - disko.mountScript diskFormat pkgs - else if (mode = "zap_create_mount") then - disko.zapCreateMount diskFormat pkgs + diskoEval = if noDeps then + if (mode == "create") then + disko.createScriptNoDeps diskFormat pkgs + else if (mode == "mount") then + disko.mountScriptNoDeps diskFormat pkgs + else if (mode == "zap_create_mount") then + disko.zapCreateMountScriptNoDeps diskFormat pkgs + else + builtins.abort "invalid mode" else - builtins.abort "invalid mode" + if (mode == "create") then + disko.createScript diskFormat pkgs + else if (mode == "mount") then + disko.mountScript diskFormat pkgs + else if (mode == "zap_create_mount") then + disko.zapCreateMount diskFormat pkgs + else + builtins.abort "invalid mode" ; in diskoEval diff --git a/default.nix b/default.nix index 03a6833..bc975a7 100644 --- a/default.nix +++ b/default.nix @@ -16,18 +16,34 @@ in { types = types; create = cfg: types.diskoLib.create (eval cfg).config.devices; createScript = cfg: pkgs: pkgs.writeScript "disko-create" '' + #!/usr/bin/env bash export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)} ${types.diskoLib.create (eval cfg).config.devices} ''; + createScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-create" '' + #!/usr/bin/env bash + ${types.diskoLib.create (eval cfg).config.devices} + ''; mount = cfg: types.diskoLib.mount (eval cfg).config.devices; mountScript = cfg: pkgs: pkgs.writeScript "disko-mount" '' + #!/usr/bin/env bash export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)} ${types.diskoLib.mount (eval cfg).config.devices} ''; - zapCreateMount = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" '' + mountScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-mount" '' + #!/usr/bin/env bash + ${types.diskoLib.mount (eval cfg).config.devices} + ''; + zapCreateMount = cfg: types.diskoLib.zapCreateMount (eval cfg).config.devices; + zapCreateMountScript = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" '' + #!/usr/bin/env bash export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)} ${types.diskoLib.zapCreateMount (eval cfg).config.devices} ''; + zapCreateMountScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" '' + #!/usr/bin/env bash + ${types.diskoLib.zapCreateMount (eval cfg).config.devices} + ''; config = cfg: { imports = types.diskoLib.config (eval cfg).config.devices; }; packages = cfg: types.diskoLib.packages (eval cfg).config.devices; } diff --git a/disko b/disko index a48907f..7e4f0bf 100755 --- a/disko +++ b/disko @@ -72,6 +72,9 @@ while [[ $# -gt 0 ]]; do --dry-run) dry_run=y ;; + --no-deps) + nix_args+=(--arg noDeps true) + ;; --show-trace) nix_args+=("$1") ;; -- cgit v1.2.3