Skip to content

Commit fa2b0fa

Browse files
nix whacks
1 parent f401385 commit fa2b0fa

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

content/nix_whacks.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
+++
2+
title = "Nix whacks"
3+
date = 2025-04-28
4+
[taxonomies]
5+
tags = ["nix"]
6+
+++
7+
8+
A loose collection of useful nix snippets.
9+
10+
## Patch-in a PR while building a package
11+
12+
Say, we want to include the [147th PR to done.fish](https://github.com/franciscolourenco/done/pull/147)
13+
14+
* append `.diff` or `.patch` to the url, which will redirect you to [https://patch-diff.githubusercontent.com/raw/franciscolourenco/done/pull/147.diff](https://patch-diff.githubusercontent.com/raw/franciscolourenco/done/pull/147.diff)
15+
* pull and apply the patch via nix:
16+
17+
```nix
18+
(fishPlugins.done.overrideAttrs (final: prev: {
19+
patches = [(fetchpatch {
20+
url = "https://patch-diff.githubusercontent.com/raw/franciscolourenco/done/pull/147.diff";
21+
hash = "sha256-tIXVfXLSLwc54Z3HZcfwgGv1vEzAaBVNAjeq4vVNxNI=";
22+
})];
23+
}))
24+
```
25+
26+
[[Source](https://discourse.nixos.org/t/easiest-way-to-include-nixpkgs-pull-request/39307/3)]
27+
28+
## Overriding non-trivial builders
29+
30+
Default `overrideAttrs` is applied to the result of various `buildRustPackage`s and `buildGoModule`s, so if you want to override some builder-specific stuff (like `cargoHash`), you need to `override` the builder instead:
31+
32+
```nix
33+
(tectonic-unwrapped.override (old: {
34+
rustPlatform = old.rustPlatform // {
35+
buildRustPackage = args: old.rustPlatform.buildRustPackage (args // {
36+
# override src/cargoHash/buildFeatures here
37+
});
38+
};
39+
}))
40+
```
41+
42+
[[Source](https://discourse.nixos.org/t/is-it-possible-to-override-cargosha256-in-buildrustpackage/4393/9)]

0 commit comments

Comments
 (0)