Skip to content

Commit 4538876

Browse files
committed
Migrate from flake-utils to flake-parts
- Replace flake-utils with flake-parts and nix-systems/default - Add nixfmt-rfc-style formatter - Update README.md Nix section to document packages.default
1 parent cd18695 commit 4538876

5 files changed

Lines changed: 211 additions & 132 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ Icecream-cpp can be included as a flakes input:
167167
inputs.icecream-cpp.url = "github:renatoGarcia/icecream-cpp";
168168
```
169169

170-
The flake defines an overlay for use when importing `nixpkgs`:
170+
The package can be referenced directly:
171+
```Nix
172+
inputs.icecream-cpp.packages.${system}.default
173+
```
174+
175+
Alternatively, the flake provides an overlay for use when importing `nixpkgs`:
171176
```Nix
172177
import nixpkgs {
173178
system = "x86_64-linux";

ci_images/flake.nix

Lines changed: 85 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,100 @@
77
nixpkgs_23_11.url = "nixpkgs/nixos-23.11";
88
};
99

10-
outputs = { self, nixpkgs_24_11, nixpkgs_24_05, nixpkgs_23_11 }:
11-
let
12-
lib = nixpkgs_24_11.lib;
10+
outputs =
11+
{
12+
self,
13+
nixpkgs_24_11,
14+
nixpkgs_24_05,
15+
nixpkgs_23_11,
16+
}:
17+
let
18+
lib = nixpkgs_24_11.lib;
1319

14-
ci-docker = { pkgs, stdenv, tagname }:
15-
pkgs.dockerTools.buildLayeredImage {
16-
name = "renatogarcia/icecream-ci";
17-
tag = tagname;
20+
ci-docker =
21+
{
22+
pkgs,
23+
stdenv,
24+
tagname,
25+
}:
26+
pkgs.dockerTools.buildLayeredImage {
27+
name = "renatogarcia/icecream-ci";
28+
tag = tagname;
1829

19-
contents = with pkgs; [
20-
busybox
21-
cmake
22-
conan
23-
gnumake
24-
stdenv.cc
25-
];
30+
contents = with pkgs; [
31+
busybox
32+
cmake
33+
conan
34+
gnumake
35+
stdenv.cc
36+
];
2637

27-
# Required by clang using mktemp and failing when /tmp doesn't exist.
28-
extraCommands = ''
38+
# Required by clang using mktemp and failing when /tmp doesn't exist.
39+
extraCommands = ''
2940
mkdir -p tmp
30-
'';
41+
'';
3142

32-
config = {
33-
WorkingDir = "/home";
34-
Env =
35-
# Required so that the linker can find the libc++ when compiling with clang
36-
lib.lists.optionals (stdenv.cc.libcxx != null) [
37-
"NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1"
38-
(
39-
let
40-
# clang8 depends on libc++abi besides libc++
41-
findLibcxxabi = depsList: lib.lists.findFirst (drv: drv.pname == "libcxxabi") null depsList;
42-
libcxxabi = findLibcxxabi (lib.lists.remove null stdenv.cc.libcxx.buildInputs);
43-
in
44-
if libcxxabi != null
45-
then "NIX_LDFLAGS=-L${stdenv.cc.libcxx}/lib/ -L${libcxxabi.out}/lib"
46-
else "NIX_LDFLAGS=-L${stdenv.cc.libcxx}/lib/"
47-
)
48-
];
43+
config = {
44+
WorkingDir = "/home";
45+
Env =
46+
# Required so that the linker can find the libc++ when compiling with clang
47+
lib.lists.optionals (stdenv.cc.libcxx != null) [
48+
"NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1"
49+
(
50+
let
51+
# clang8 depends on libc++abi besides libc++
52+
findLibcxxabi = depsList: lib.lists.findFirst (drv: drv.pname == "libcxxabi") null depsList;
53+
libcxxabi = findLibcxxabi (lib.lists.remove null stdenv.cc.libcxx.buildInputs);
54+
in
55+
if libcxxabi != null then
56+
"NIX_LDFLAGS=-L${stdenv.cc.libcxx}/lib/ -L${libcxxabi.out}/lib"
57+
else
58+
"NIX_LDFLAGS=-L${stdenv.cc.libcxx}/lib/"
59+
)
60+
];
61+
};
4962
};
50-
};
5163

52-
pkgs_24_11 = import nixpkgs_24_11 {
53-
system = "x86_64-linux";
54-
};
64+
pkgs_24_11 = import nixpkgs_24_11 {
65+
system = "x86_64-linux";
66+
};
5567

56-
pkgs_24_05 = import nixpkgs_24_05 {
57-
system = "x86_64-linux";
58-
};
68+
pkgs_24_05 = import nixpkgs_24_05 {
69+
system = "x86_64-linux";
70+
};
5971

60-
pkgs_23_11 = import nixpkgs_23_11 {
61-
system = "x86_64-linux";
62-
};
72+
pkgs_23_11 = import nixpkgs_23_11 {
73+
system = "x86_64-linux";
74+
};
6375

64-
in
65-
{
66-
packages.x86_64-linux = {
67-
ci-gcc6 = ci-docker { pkgs = pkgs_24_11; stdenv = pkgs_24_05.gcc6Stdenv; tagname = "gcc6-3"; };
68-
ci-gcc9 = ci-docker { pkgs = pkgs_24_11; stdenv = pkgs_24_11.gcc9Stdenv; tagname = "gcc9-3"; };
69-
ci-gcc14 = ci-docker { pkgs = pkgs_24_11; stdenv = pkgs_24_11.gcc14Stdenv; tagname = "gcc14-3"; };
70-
ci-clang8 = ci-docker { pkgs = pkgs_24_11; stdenv = pkgs_23_11.llvmPackages_8.libcxxStdenv; tagname = "clang8-3"; };
71-
ci-clang19 = ci-docker { pkgs = pkgs_24_11; stdenv = pkgs_24_11.llvmPackages_19.libcxxStdenv; tagname = "clang19-3"; };
76+
in
77+
{
78+
packages.x86_64-linux = {
79+
ci-gcc6 = ci-docker {
80+
pkgs = pkgs_24_11;
81+
stdenv = pkgs_24_05.gcc6Stdenv;
82+
tagname = "gcc6-3";
83+
};
84+
ci-gcc9 = ci-docker {
85+
pkgs = pkgs_24_11;
86+
stdenv = pkgs_24_11.gcc9Stdenv;
87+
tagname = "gcc9-3";
88+
};
89+
ci-gcc14 = ci-docker {
90+
pkgs = pkgs_24_11;
91+
stdenv = pkgs_24_11.gcc14Stdenv;
92+
tagname = "gcc14-3";
93+
};
94+
ci-clang8 = ci-docker {
95+
pkgs = pkgs_24_11;
96+
stdenv = pkgs_23_11.llvmPackages_8.libcxxStdenv;
97+
tagname = "clang8-3";
98+
};
99+
ci-clang19 = ci-docker {
100+
pkgs = pkgs_24_11;
101+
stdenv = pkgs_24_11.llvmPackages_19.libcxxStdenv;
102+
tagname = "clang19-3";
103+
};
104+
};
72105
};
73-
};
74106
}

example_project/flake.nix

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
};
1111
};
1212

13-
outputs = inputs@{ self, nixpkgs, ... }:
13+
outputs =
14+
inputs@{ self, nixpkgs, ... }:
1415
let
15-
application = { pkgs }:
16+
application =
17+
{ pkgs }:
1618
pkgs.stdenv.mkDerivation {
1719
pname = "icecream-example";
1820
version = "1.0";
@@ -27,14 +29,17 @@
2729
];
2830
};
2931

30-
pkgs = (import nixpkgs {
31-
system = "x86_64-linux";
32-
overlays = [
33-
inputs.icecream-cpp.overlays.default
34-
];
35-
});
32+
pkgs = (
33+
import nixpkgs {
34+
system = "x86_64-linux";
35+
overlays = [
36+
inputs.icecream-cpp.overlays.default
37+
];
38+
}
39+
);
3640

37-
in {
41+
in
42+
{
3843
packages.x86_64-linux = {
3944
default = application { inherit pkgs; };
4045
};

flake.lock

Lines changed: 27 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)