diff options
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap/utils.nix')
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/utils.nix | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/utils.nix b/pkgs/os-specific/linux/minimal-bootstrap/utils.nix index 1cc56654d7b..e710c34aa6a 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/utils.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/utils.nix @@ -2,7 +2,6 @@ , buildPlatform , callPackage , kaem -, mescc-tools , mescc-tools-extra }: @@ -19,14 +18,18 @@ rec { passthru = attrs.passthru or {}; validity = checkMeta.assertValidity { inherit meta attrs; }; meta = checkMeta.commonMeta { inherit validity attrs; }; + baseDrv = derivation ({ + inherit (buildPlatform) system; + inherit (meta) name; + } // (builtins.removeAttrs attrs [ "meta" "passthru" ])); + passthru' = passthru // lib.optionalAttrs (passthru ? tests) { + tests = lib.mapAttrs (_: f: f baseDrv) passthru.tests; + }; in lib.extendDerivation validity.handled - ({ inherit meta passthru; } // passthru) - (derivation ({ - inherit (buildPlatform) system; - inherit (meta) name; - } // (builtins.removeAttrs attrs [ "meta" "passthru" ]))); + ({ inherit meta; passthru = passthru'; } // passthru') + baseDrv; writeTextFile = { name # the name of the derivation @@ -37,7 +40,7 @@ rec { , preferLocalBuild ? true }: derivationWithMeta { - inherit name text executable allowSubstitutes preferLocalBuild; + inherit name text allowSubstitutes preferLocalBuild; passAsFile = [ "text" ]; builder = "${kaem}/bin/kaem"; @@ -45,39 +48,22 @@ rec { "--verbose" "--strict" "--file" - (builtins.toFile "write-text-file.kaem" '' + (builtins.toFile "write-text-file.kaem" ('' target=''${out}''${destination} - if match x''${mkdirDestination} x1; then - mkdir -p ''${out}''${destinationDir} - fi + '' + lib.optionalString (builtins.dirOf destination == ".") '' + mkdir -p ''${out}''${destinationDir} + '' + '' cp ''${textPath} ''${target} - if match x''${executable} x1; then - chmod 555 ''${target} - fi - '') + '' + lib.optionalString executable '' + chmod 555 ''${target} + '')) ]; PATH = lib.makeBinPath [ mescc-tools-extra ]; - mkdirDestination = if builtins.dirOf destination == "." then "0" else "1"; destinationDir = builtins.dirOf destination; inherit destination; }; writeText = name: text: writeTextFile {inherit name text;}; - runCommand = name: env: buildCommand: - derivationWithMeta ({ - inherit name; - - builder = "${kaem}/bin/kaem"; - args = [ - "--verbose" - "--strict" - "--file" - (writeText "${name}-builder" buildCommand) - ]; - - PATH = lib.makeBinPath ((env.nativeBuildInputs or []) ++ [ kaem mescc-tools mescc-tools-extra ]); - } // (builtins.removeAttrs env [ "nativeBuildInputs" ])); - } |