The 1.8.6 bump (#527044) broke the package on darwin in two independent
ways, unnoticed because the package is unfree and therefore never built
by Hydra or ofborg:
- postInstall generates shell completions by running $out/bin/gt, but
gt tries to create ~/.config/graphite/aliases on startup and exits 1
with no output when HOME is not writable (as in nix builds, where
HOME=/homeless-shelter). installShellCompletion then fails the build
because the generated completion files are zero-size. Give the build
a throwaway writable HOME. The Linux build is not affected because
completions are generated through the buildFHSEnv wrapper, where /
is a writable tmpfs.
- dontFixup was only set on Linux, so on darwin fixupPhase ran strip -S
on the binary. As the comment in this file already explains, the
vercel/pkg virtual filesystem appended to the binary must not be
modified; the stripped binary fails at runtime with "Pkg: Error
reading from file." Skip fixup on all platforms. On Linux this is a
no-op: the derivation is unchanged.
Assisted-by: Devin (Ultra)
Co-Authored-By: Rahul Chalamala <22563365+rchalamala@users.noreply.github.com>
Since 1.8, graphite has started relying on binary packages prebuilt per host
platform, kind of like obsidian. Therefore, to support newer versions of
graphite, I've altered the package definition to download those binary packages
directly (one for each platform). On Linux we need a FHS environment wrapper,
which makes the code a bit more complex.
I've taken the liberty of also adding a version check to the package.
This treewide conditions execution of the built applications for the purpose of generating shell completions behind `stdenv.buildPlatform.canExecute stdenv.hostPlatform`, which helps cross. This is a common issue I spot during review, let's prevent copy-paste errors by fixing it treewide.
Candidates were located with:
```shell
rg 'installShellCompletion' -l -tnix | xargs grep -F 'stdenv.buildPlatform.canExecute stdenv.hostPlatform' -L
```
Then I migrated the obvious cases which would not require a rebuild, as a means of testing.
This diff was not scripted. Should be zero rebuilds.
<details>
<summary>
Alternatives
</summary>
Alternatively I could have use this pattern:
```nix
postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
let
emulator = stdenv.hostPlatform.emulator buildPackages;
in
''
installShellCompletion --cmd foobar \
--bash <(${emulator} $out/bin/foobar completion bash) \
--fish <(${emulator} $out/bin/foobar completion fish) \
--zsh <(${emulator} $out/bin/foobar completion zsh)
''
);
```
but that would cause rebuilds and will also require testing.
---
An other alternative is to use the binary from the corresponding package in `buildPackages`.
This however would also cause rebuilds and will also require testing.
</details>
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH