Skip to content

Commit 73877f8

Browse files
committed
add template showing nixpkgs option usage
1 parent 8f7c59e commit 73877f8

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
description = "Default template suitable as starting point";
2222
path = ./templates/default;
2323
};
24+
nixpkgs = {
25+
description = "Template showing nixpkgs overlay being applied";
26+
path = ./templates/nixpkgs;
27+
};
2428
};
2529
};
2630
}

templates/nixpkgs/default.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+
5+
conch = {
6+
url = "github:mibmo/conch";
7+
inputs.nixpkgs.follows = "nixpkgs";
8+
};
9+
};
10+
11+
outputs =
12+
{ conch, ... }:
13+
conch.configure {
14+
nixpkgs.overlays = [
15+
(self: super: {
16+
hello = super.hello.overrideAttrs (
17+
final: prev: {
18+
patches = prev.patches or [ ] ++ [
19+
(builtins.toFile "hello-message.patch" ''
20+
diff '--color=auto' -urpN old/src/hello.c new/src/hello.c
21+
--- old/src/hello.c 2026-01-17 20:24:39.000000000 +0100
22+
+++ new/src/hello.c 2026-06-09 19:10:47.953160544 +0200
23+
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
24+
#endif
25+
26+
/* Having initialized gettext, get the default message. */
27+
- greeting_msg = _("Hello, world!");
28+
+ greeting_msg = _("Hello, conch!");
29+
30+
/* Even exiting has subtleties. On exit, if any writes failed, change
31+
the exit status. The /dev/full device on GNU/Linux can be used for
32+
'')
33+
];
34+
doCheck = false;
35+
}
36+
);
37+
})
38+
];
39+
packages =
40+
{ pkgs, ... }:
41+
{
42+
# this references `pkgs`, so uses patched version
43+
inherit (pkgs) hello;
44+
};
45+
devShells.default =
46+
{ pkgs, ... }:
47+
{
48+
# same here! try entering the dev shell!
49+
packages = with pkgs; [ hello ];
50+
hook = "hello";
51+
};
52+
};
53+
}

0 commit comments

Comments
 (0)