Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow accessing correct pkgs during preSignCommands #247

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

jmbaur
Copy link
Contributor

@jmbaur jmbaur commented Sep 26, 2024

Description of changes

preSignCommands is used in two different contexts, when building derivations that are using the package-set defined in the NixOS config for a machine (defaults to a native aarch64-linux package-set) and when building flash scripts (defaults to a native x86_64-linux package-set). In order to support the use-case of using nix outputs obtained from a package-set within preSignCommands, the value set in this option must not carry in any output paths from package-sets defined elsewhere. For example, the following configuration is problematic and will not work when building the flash script, due to pkgs having a hostPlatform of aarch64-linux, thus hello will be an ELF binary targeting aarch64-linux:

{ pkgs, ... }: {
  hardware.nvidia-jetpack.firmware.secureBoot.preSignCommands = ''
    ${pkgs.hello}/bin/hello
  '';
}

The correct usage would be:

{ ... }: {
  hardware.nvidia-jetpack.firmware.secureBoot.preSignCommands = pkgs: ''
    ${pkgs.hello}/bin/hello
  '';
}
Testing

Tested building a simple config with the example above and ensuring we do not get an error running hello.

`preSignCommands` is used in two different contexts, when building
derivations that are using the package-set defined in the NixOS config
for a machine (defaults to a native aarch64-linux package-set) and when
building flash scripts (defaults to a native x86_64-linux package-set).
In order to support the use-case of using nix outputs obtained from a
package-set within `preSignCommands`, the value set in this option must
not carry in any output paths from package-sets defined elsewhere. For
example, the following configuration is problematic and will not work
when building the flash script, due to `pkgs` having a `hostPlatform` of
aarch64-linux, thus `hello` will be an ELF binary targeting
aarch64-linux:

```nix
{ pkgs, ... }: {
  hardware.nvidia-jetpack.firmware.secureBoot.preSignCommands = ''
    ${pkgs.hello}/bin/hello
  '';
}
```

The correct usage would be:
```nix
{ ... }: {
  hardware.nvidia-jetpack.firmware.secureBoot.preSignCommands = pkgs: ''
    ${pkgs.hello}/bin/hello
  '';
}
```
@danielfullmer danielfullmer merged commit 306d921 into anduril:master Sep 26, 2024
1 check failed
@jmbaur jmbaur deleted the pre-sign-commands-pkgs branch September 26, 2024 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants