-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
114 lines (98 loc) · 3.16 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
by-name.url = "github:mightyiam/by-name";
crane.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
fenix.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
flake-utils.url = "github:numtide/flake-utils";
github-graphql-schema.flake = false;
github-graphql-schema.url = "github:octokit/graphql-schema";
nmd.inputs.nixpkgs.follows = "nixpkgs";
nmd.url = "git+https://git.sr.ht/~rycee/nmd";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = {
self,
nixpkgs,
by-name,
crane,
flake-utils,
github-graphql-schema,
nmd,
treefmt-nix,
...
} @ inputs: let
inherit (nixpkgs) lib;
inherit
(lib)
attrValues
mkOption
;
flattenTree = import ./flattenTree.nix;
GITHUB_GRAPHQL_SCHEMA = "${github-graphql-schema}/schema.graphql";
forEachDefaultSystem = system: let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
fenix = inputs.fenix.packages.${system};
nmdLib = nmd.lib.${system};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
inherit
(pkgs)
mkShell
newScope
sqlx-cli
writeShellApplication
;
inherit
(import ./packages {
inherit lib pkgs by-name craneLib fenix nixpkgs nmdLib GITHUB_GRAPHQL_SCHEMA;
pr-tracker = self;
})
packages
clippyCheck
;
devUtils = [
(writeShellApplication {
name = "util-sqlx-prepare";
runtimeInputs = [sqlx-cli];
text = "cargo run --package util --bin sqlx-prepare";
})
(writeShellApplication {
name = "util-db-repl";
text = "cargo run --package util --bin db-repl";
})
];
nixosTestsByName = by-name.lib.trivial (newScope {pr-tracker = self;});
nixosTests = nixosTestsByName ./nixos-tests;
in {
inherit packages;
apps = import ./release {inherit pkgs flake-utils;};
devShells.default = mkShell {
inherit GITHUB_GRAPHQL_SCHEMA;
inputsFrom = attrValues packages;
packages = [sqlx-cli] ++ devUtils;
SQLX_OFFLINE = "true";
};
checks = flattenTree {
inherit packages nixosTests;
clippy = clippyCheck;
formatting = treefmtEval.config.build.check self;
filterOptions = assert (import ./filterOptions-check.nix lib); pkgs.hello;
};
formatter = treefmtEval.config.build.wrapper;
};
systemSpecificOutputs = flake-utils.lib.eachDefaultSystem forEachDefaultSystem;
mkPublicModule = path: {pkgs, ...}: {
imports = [path];
options._pr-tracker-packages = mkOption {internal = true;};
config._pr-tracker-packages = self.packages.${pkgs.system};
};
systemAgnosticOutputs.nixosModules.api = mkPublicModule ./modules/api.nix;
systemAgnosticOutputs.nixosModules.fetcher = mkPublicModule ./modules/fetcher.nix;
in
systemSpecificOutputs
// systemAgnosticOutputs;
}