Skip to content

Commit 5665713

Browse files
committed
1 parent 68cbecf commit 5665713

25 files changed

+1120
-1075
lines changed

default.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
let
22
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
3-
inherit (lock.nodes.flake-compat.locked) owner repo rev narHash;
3+
inherit (lock.nodes.flake-compat.locked)
4+
owner
5+
repo
6+
rev
7+
narHash
8+
;
49
flake-compat = fetchTarball {
510
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
611
sha256 = narHash;
712
};
8-
thisFlake = import flake-compat {src = ./.;};
13+
thisFlake = import flake-compat { src = ./.; };
914
in
10-
thisFlake.defaultNix
15+
thisFlake.defaultNix

flake.nix

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
description = "Nix packages for D projects";
33

44
nixConfig = {
5-
extra-substituters = ["https://dlang-community.cachix.org"];
6-
extra-trusted-public-keys = ["dlang-community.cachix.org-1:eAX1RqX4PjTDPCAp/TvcZP+DYBco2nJBackkAJ2BsDQ="];
5+
extra-substituters = [ "https://dlang-community.cachix.org" ];
6+
extra-trusted-public-keys = [
7+
"dlang-community.cachix.org-1:eAX1RqX4PjTDPCAp/TvcZP+DYBco2nJBackkAJ2BsDQ="
8+
];
79
};
810

911
inputs = {
@@ -17,33 +19,45 @@
1719
};
1820
};
1921

20-
outputs = inputs @ {
21-
self,
22-
nixpkgs,
23-
flake-parts,
24-
...
25-
}:
26-
flake-parts.lib.mkFlake {inherit inputs;} {
27-
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
28-
imports = [./pkgs ./lib/mk-gh-actions-matrix.nix];
22+
outputs =
23+
inputs@{
24+
self,
25+
nixpkgs,
26+
flake-parts,
27+
...
28+
}:
29+
flake-parts.lib.mkFlake { inherit inputs; } {
30+
systems = [
31+
"x86_64-linux"
32+
"aarch64-linux"
33+
"x86_64-darwin"
34+
"aarch64-darwin"
35+
];
36+
imports = [
37+
./pkgs
38+
./lib/mk-gh-actions-matrix.nix
39+
];
2940

30-
perSystem = {pkgs, ...}: {
31-
devShells.default = import ./shells/default.nix {inherit pkgs;};
32-
devShells.ci = import ./shells/ci.nix {inherit pkgs;};
33-
};
41+
perSystem =
42+
{ pkgs, ... }:
43+
{
44+
devShells.default = import ./shells/default.nix { inherit pkgs; };
45+
devShells.ci = import ./shells/ci.nix { inherit pkgs; };
46+
};
3447

35-
flake.templates = let
36-
lib = nixpkgs.lib;
37-
allTemplates = lib.pipe (builtins.readDir ./templates) [
38-
(lib.filterAttrs (k: v: v == "directory"))
39-
(builtins.mapAttrs (k: v: rec {
40-
path = ./templates + "/${k}";
41-
description = lib.removeSuffix "\n" (
42-
builtins.readFile (path + "/description.txt")
43-
);
44-
}))
45-
];
46-
in
48+
flake.templates =
49+
let
50+
lib = nixpkgs.lib;
51+
allTemplates = lib.pipe (builtins.readDir ./templates) [
52+
(lib.filterAttrs (k: v: v == "directory"))
53+
(builtins.mapAttrs (
54+
k: v: rec {
55+
path = ./templates + "/${k}";
56+
description = lib.removeSuffix "\n" (builtins.readFile (path + "/description.txt"));
57+
}
58+
))
59+
];
60+
in
4761
allTemplates;
4862
};
4963
}

lib/build-status.nix

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
{lib, ...}: {
2-
getBuildStatus = package: version: system: let
3-
data = import ./../pkgs/${package}/build-status.nix {inherit lib;};
4-
in
5-
data.${version}.${system}
6-
or {
1+
{ lib, ... }:
2+
{
3+
getBuildStatus =
4+
package: version: system:
5+
let
6+
data = import ./../pkgs/${package}/build-status.nix { inherit lib; };
7+
in
8+
data.${version}.${system} or {
79
# If not build status is found, we assume that the package builds
810
# successfully with no workarounds.
911
build = true;
1012
check = true;
11-
skippedTests = [];
13+
skippedTests = [ ];
1214
};
1315
}

lib/mk-gh-actions-matrix.nix

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1+
{ lib, self, ... }:
12
{
2-
lib,
3-
self,
4-
...
5-
}: {
63
flake = {
74
lib = rec {
85
# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
@@ -19,41 +16,39 @@
1916
"aarch64-darwin" = "flyci-macos-large-latest-m1";
2017
};
2118

22-
inherit (import ./build-status.nix {inherit lib;}) getBuildStatus;
19+
inherit (import ./build-status.nix { inherit lib; }) getBuildStatus;
2320

2421
allowedToFailMap = lib.pipe (mkGHActionsMatrix.include) [
2522
(builtins.groupBy (p: p.package))
2623
(builtins.mapAttrs (
27-
n: v:
28-
builtins.mapAttrs (
29-
s: ps:
30-
(builtins.head ps).allowedToFail
31-
)
32-
(builtins.groupBy (p: p.system) v)
24+
n: v: builtins.mapAttrs (s: ps: (builtins.head ps).allowedToFail) (builtins.groupBy (p: p.system) v)
3325
))
3426
];
3527

3628
mkGHActionsMatrix = {
3729
include = lib.pipe (builtins.attrNames nixSystemToGHPlatform) [
38-
(builtins.concatMap
39-
(
40-
system: let
41-
platform = nixSystemToGHPlatform.${system};
30+
(builtins.concatMap (
31+
system:
32+
let
33+
platform = nixSystemToGHPlatform.${system};
34+
in
35+
map (
36+
package:
37+
let
38+
p = self.packages.${system}.${package};
4239
in
43-
map (package: let
44-
p = self.packages.${system}.${package};
45-
in {
46-
os = platform;
47-
allowedToFail = !(p.passthru.buildStatus or (throw "${package} does not expose build status")).build;
48-
inherit system package;
49-
attrPath = "packages.${system}.${lib.strings.escapeNixIdentifier package}";
50-
})
51-
(builtins.attrNames self.packages.${system})
52-
))
53-
(builtins.sort (a: b:
54-
if (a.package == b.package)
55-
then a.os == "ubuntu-latest"
56-
else a.package < b.package))
40+
{
41+
os = platform;
42+
allowedToFail =
43+
!(p.passthru.buildStatus or (throw "${package} does not expose build status")).build;
44+
inherit system package;
45+
attrPath = "packages.${system}.${lib.strings.escapeNixIdentifier package}";
46+
}
47+
) (builtins.attrNames self.packages.${system})
48+
))
49+
(builtins.sort (
50+
a: b: if (a.package == b.package) then a.os == "ubuntu-latest" else a.package < b.package
51+
))
5752
];
5853
};
5954
};

lib/version-catalog.nix

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
{
2-
lib,
3-
pkgs,
4-
...
5-
}: let
6-
inherit (builtins) attrNames listToAttrs map mapAttrs;
1+
{ lib, pkgs, ... }:
2+
let
3+
inherit (builtins)
4+
attrNames
5+
listToAttrs
6+
map
7+
mapAttrs
8+
;
79
inherit (lib) nameValuePair pipe optional;
810

911
inherit (pkgs) callPackage;
@@ -12,61 +14,51 @@
1214
};
1315

1416
system = pkgs.hostPlatform.system;
15-
filterBySystem = pkgs:
16-
lib.filterAttrs
17-
(_name: pkg: builtins.elem system pkg.meta.platforms)
18-
pkgs;
19-
in {
20-
genPkgVersions = pkgName: let
21-
mod = ../pkgs/${pkgName}/version-catalog.nix;
22-
inherit
23-
(import mod)
24-
supportedVersions
25-
getSourceVersion
26-
getBinaryVersion
27-
;
17+
filterBySystem = pkgs: lib.filterAttrs (_name: pkg: builtins.elem system pkg.meta.platforms) pkgs;
18+
in
19+
{
20+
genPkgVersions =
21+
pkgName:
22+
let
23+
mod = ../pkgs/${pkgName}/version-catalog.nix;
24+
inherit (import mod) supportedVersions getSourceVersion getBinaryVersion;
2825

29-
supportedTypes =
30-
(optional (getBinaryVersion != null) "binary")
31-
++ (optional (getSourceVersion != null) "source");
26+
supportedTypes =
27+
(optional (getBinaryVersion != null) "binary") ++ (optional (getSourceVersion != null) "source");
3228

33-
sanitizeVersion = version: builtins.replaceStrings ["."] ["_"] version;
29+
sanitizeVersion = version: builtins.replaceStrings [ "." ] [ "_" ] version;
3430

35-
getVersion = type:
36-
if type == "source"
37-
then getSourceVersion
38-
else getBinaryVersion;
39-
in {
40-
flattened = type: let
41-
nameSuffix =
42-
if type == "binary"
43-
then "-binary"
44-
else "";
31+
getVersion = type: if type == "source" then getSourceVersion else getBinaryVersion;
4532
in
46-
pipe (attrNames supportedVersions."${type}") [
47-
(
48-
map (
33+
{
34+
flattened =
35+
type:
36+
let
37+
nameSuffix = if type == "binary" then "-binary" else "";
38+
in
39+
pipe (attrNames supportedVersions."${type}") [
40+
(map (
4941
version:
50-
nameValuePair
51-
"${pkgName}${nameSuffix}-${sanitizeVersion version}"
52-
(callPackage (getVersion type version) darwinPkgs)
53-
)
54-
)
55-
listToAttrs
56-
filterBySystem
57-
];
42+
nameValuePair "${pkgName}${nameSuffix}-${sanitizeVersion version}" (
43+
callPackage (getVersion type version) darwinPkgs
44+
)
45+
))
46+
listToAttrs
47+
filterBySystem
48+
];
5849

59-
hierarchical = {
60-
"${pkgName}" = pipe supportedTypes [
61-
(map (type:
62-
nameValuePair type (
63-
mapAttrs
64-
(version: _: (callPackage (getVersion type version) darwinPkgs))
65-
supportedVersions."${type}"
66-
)))
67-
listToAttrs
68-
filterBySystem
69-
];
50+
hierarchical = {
51+
"${pkgName}" = pipe supportedTypes [
52+
(map (
53+
type:
54+
nameValuePair type (
55+
mapAttrs (version: _: (callPackage (getVersion type version) darwinPkgs))
56+
supportedVersions."${type}"
57+
)
58+
))
59+
listToAttrs
60+
filterBySystem
61+
];
62+
};
7063
};
71-
};
7264
}

lib/version-utils.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{...}: {
2-
versionBetween = after: before: version:
3-
((builtins.compareVersions version after) >= 0)
4-
&& ((builtins.compareVersions version before) < 0);
1+
{ ... }:
2+
{
3+
versionBetween =
4+
after: before: version:
5+
((builtins.compareVersions version after) >= 0) && ((builtins.compareVersions version before) < 0);
56
}

0 commit comments

Comments
 (0)