Unverified Commit 9c7c6cc7 authored by nixpkgs-ci[bot]'s avatar nixpkgs-ci[bot] Committed by GitHub
Browse files

Merge staging-next into staging

parents 5105cb59 a210e0d3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -202,6 +202,10 @@ Similarly, if you encounter errors similar to `Error_Protocol ("certificate has

  _Default value:_ `false`.

`meta` (Attribute Set)

: The `meta` attribute of the resulting derivation, as in `stdenv.mkDerivation`. Accepts `description`, `maintainers` and any other `meta` attributes.

`contents` **DEPRECATED**

: This attribute is deprecated, and users are encouraged to use `copyToRoot` instead.
@@ -635,6 +639,10 @@ This allows the function to produce reproducible images.

  _Default value:_ `false`.

`meta` (Attribute Set)

: The `meta` attribute of the resulting derivation, as in `stdenv.mkDerivation`. Accepts `description`, `maintainers` and any other `meta` attributes.

`passthru` (Attribute Set; _optional_)

: Use this to pass any attributes as [`passthru`](#chap-passthru) for the resulting derivation.
+5 −1
Original line number Diff line number Diff line
@@ -64,13 +64,15 @@ builders = ssh-ng://builder@linux-builder ${ARCH}-linux /etc/nix/builder_ed25519
builders-use-substitutes = true
```

To allow Nix to connect to a remote builder not running on port 22, you will also need to create a new file at `/etc/ssh/ssh_config.d/100-linux-builder.conf`:
To allow Nix to connect to the default remote builder, which does not run on port 22, you will also need to create a new file at `/etc/ssh/ssh_config.d/100-linux-builder.conf`:

```
Host linux-builder
  Hostname localhost
  HostKeyAlias linux-builder
  Port 31022
  User builder
  IdentityFile /etc/nix/builder_ed25519
```

… and then restart your Nix daemon to apply the change:
@@ -79,6 +81,8 @@ Host linux-builder
$ sudo launchctl kickstart -k system/org.nixos.nix-daemon
```

Note that if the builder is running and you have created the above ssh conf file, you can ssh into the builder with `sudo ssh builder@linux-builder`.

## Example flake usage {#sec-darwin-builder-example-flake}

```nix
+135 −0
Original line number Diff line number Diff line
@@ -864,4 +864,139 @@ rec {
        transformDrv
        ;
    };

  /**
    Removes a prefix from the attribute names of a cross index.

    A cross index (short for "Cross Platform Pair Index") is a 6-field structure
    organizing values by cross-compilation platform relationships.

    # Inputs

    `prefix`
    : The prefix to remove from cross index attribute names

    `crossIndex`
    : A cross index with prefixed names

    # Type

    ```
    renameCrossIndexFrom :: String -> AttrSet -> AttrSet
    ```

    # Examples

    :::{.example}
    ## `lib.customisation.renameCrossIndexFrom` usage example

    ```nix
    renameCrossIndexFrom "pkgs" { pkgsBuildBuild = ...; pkgsBuildHost = ...; ... }
    => { buildBuild = ...; buildHost = ...; ... }
    ```
    :::
  */
  renameCrossIndexFrom = prefix: x: {
    buildBuild = x."${prefix}BuildBuild";
    buildHost = x."${prefix}BuildHost";
    buildTarget = x."${prefix}BuildTarget";
    hostHost = x."${prefix}HostHost";
    hostTarget = x."${prefix}HostTarget";
    targetTarget = x."${prefix}TargetTarget";
  };

  /**
    Adds a prefix to the attribute names of a cross index.

    A cross index (short for "Cross Platform Pair Index") is a 6-field structure
    organizing values by cross-compilation platform relationships.

    # Inputs

    `prefix`
    : The prefix to add to cross index attribute names

    `crossIndex`
    : A cross index to be prefixed

    # Type

    ```
    renameCrossIndexTo :: String -> AttrSet -> AttrSet
    ```

    # Examples

    :::{.example}
    ## `lib.customisation.renameCrossIndexTo` usage example

    ```nix
    renameCrossIndexTo "self" { buildBuild = ...; buildHost = ...; ... }
    => { selfBuildBuild = ...; selfBuildHost = ...; ... }
    ```
    :::
  */
  renameCrossIndexTo = prefix: x: {
    "${prefix}BuildBuild" = x.buildBuild;
    "${prefix}BuildHost" = x.buildHost;
    "${prefix}BuildTarget" = x.buildTarget;
    "${prefix}HostHost" = x.hostHost;
    "${prefix}HostTarget" = x.hostTarget;
    "${prefix}TargetTarget" = x.targetTarget;
  };

  /**
    Takes a function and applies it pointwise to each field of a cross index.

    A cross index (short for "Cross Platform Pair Index") is a 6-field structure
    organizing values by cross-compilation platform relationships.

    # Inputs

    `f`
    : Function to apply to each cross index value

    `crossIndex`
    : A cross index to transform

    # Type

    ```
    mapCrossIndex :: (a -> b) -> AttrSet -> AttrSet
    ```

    # Examples

    :::{.example}
    ## `lib.customisation.mapCrossIndex` usage example

    ```nix
    mapCrossIndex (x: x * 10) { buildBuild = 1; buildHost = 2; ... }
    => { buildBuild = 10; buildHost = 20; ... }
    ```

    ```nix
    # Extract a package from package sets
    mapCrossIndex (pkgs: pkgs.hello) crossIndexedPackageSets
    ```
    :::
  */
  mapCrossIndex =
    f:
    {
      buildBuild,
      buildHost,
      buildTarget,
      hostHost,
      hostTarget,
      targetTarget,
    }:
    {
      buildBuild = f buildBuild;
      buildHost = f buildHost;
      buildTarget = f buildTarget;
      hostHost = f hostHost;
      hostTarget = f hostTarget;
      targetTarget = f targetTarget;
    };
}
+3 −0
Original line number Diff line number Diff line
@@ -397,6 +397,9 @@ let
        makeScopeWithSplicing
        makeScopeWithSplicing'
        extendMkDerivation
        renameCrossIndexFrom
        renameCrossIndexTo
        mapCrossIndex
        ;
      inherit (self.derivations) lazyDerivation optionalDrvAttr warnOnInstantiate;
      inherit (self.generators) mkLuaInline;
+78 −0
Original line number Diff line number Diff line
@@ -4741,4 +4741,82 @@ runTests {
    expected = "/non-existent/this/does/not/exist/for/real/please-dont-mess-with-your-local-fs/default.nix";
  };

  # Tests for cross index utilities

  testRenameCrossIndexFrom = {
    expr = lib.renameCrossIndexFrom "pkgs" {
      pkgsBuildBuild = "dummy-build-build";
      pkgsBuildHost = "dummy-build-host";
      pkgsBuildTarget = "dummy-build-target";
      pkgsHostHost = "dummy-host-host";
      pkgsHostTarget = "dummy-host-target";
      pkgsTargetTarget = "dummy-target-target";
    };
    expected = {
      buildBuild = "dummy-build-build";
      buildHost = "dummy-build-host";
      buildTarget = "dummy-build-target";
      hostHost = "dummy-host-host";
      hostTarget = "dummy-host-target";
      targetTarget = "dummy-target-target";
    };
  };

  testRenameCrossIndexTo = {
    expr = lib.renameCrossIndexTo "self" {
      buildBuild = "dummy-build-build";
      buildHost = "dummy-build-host";
      buildTarget = "dummy-build-target";
      hostHost = "dummy-host-host";
      hostTarget = "dummy-host-target";
      targetTarget = "dummy-target-target";
    };
    expected = {
      selfBuildBuild = "dummy-build-build";
      selfBuildHost = "dummy-build-host";
      selfBuildTarget = "dummy-build-target";
      selfHostHost = "dummy-host-host";
      selfHostTarget = "dummy-host-target";
      selfTargetTarget = "dummy-target-target";
    };
  };

  testMapCrossIndex = {
    expr = lib.mapCrossIndex (x: x * 10) {
      buildBuild = 1;
      buildHost = 2;
      buildTarget = 3;
      hostHost = 4;
      hostTarget = 5;
      targetTarget = 6;
    };
    expected = {
      buildBuild = 10;
      buildHost = 20;
      buildTarget = 30;
      hostHost = 40;
      hostTarget = 50;
      targetTarget = 60;
    };
  };

  testMapCrossIndexString = {
    expr = lib.mapCrossIndex (x: "prefix-${x}") {
      buildBuild = "bb";
      buildHost = "bh";
      buildTarget = "bt";
      hostHost = "hh";
      hostTarget = "ht";
      targetTarget = "tt";
    };
    expected = {
      buildBuild = "prefix-bb";
      buildHost = "prefix-bh";
      buildTarget = "prefix-bt";
      hostHost = "prefix-hh";
      hostTarget = "prefix-ht";
      targetTarget = "prefix-tt";
    };
  };

}
Loading