-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
flake.nix
127 lines (109 loc) · 3.44 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
115
116
117
118
119
120
121
122
123
124
125
126
127
{
description = "Discord bot for Prism Launcher";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{
self,
nixpkgs,
}:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs systems;
nixpkgsFor = nixpkgs.legacyPackages;
in
{
checks = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
mkCheck =
name: deps: script:
pkgs.runCommand name { nativeBuildInputs = deps; } ''
${script}
touch $out
'';
in
{
actionlint = mkCheck "check-actionlint" [ pkgs.actionlint ] "actionlint ${./.github/workflows}/*";
deadnix = mkCheck "check-deadnix" [ pkgs.deadnix ] "deadnix --fail ${self}";
statix = mkCheck "check-statix" [ pkgs.statix ] "statix check ${self}";
nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] "nixfmt --check ${self}";
rustfmt = mkCheck "check-rustfmt" [
pkgs.cargo
pkgs.rustfmt
] "cd ${self} && cargo fmt -- --check";
}
);
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
redis
# linters & formatters
actionlint
nodePackages.prettier
# rust tools
clippy
rustfmt
rust-analyzer
# nix tools
self.formatter.${system}
nil
statix
];
inputsFrom = [ self.packages.${pkgs.system}.refraction ];
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
};
}
);
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
nixosModules.default = import ./nix/module.nix self;
# For CI
legacyPackages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
clippy-report = pkgs.callPackage ./nix/clippy.nix { inherit (self.packages.${system}) refraction; };
refraction-debug = (self.packages.${system}.refraction.override { lto = false; }).overrideAttrs (
finalAttrs: _: {
cargoBuildType = "debug";
cargoCheckType = finalAttrs.cargoBuildType;
}
);
}
);
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
packages' = self.packages.${system};
refractionPackages = lib.makeScope pkgs.newScope (lib.flip self.overlays.default pkgs);
mkStatic = pkgs.callPackage ./nix/static.nix { };
containerize = pkgs.callPackage ./nix/containerize.nix { };
in
{
inherit (refractionPackages) refraction;
static-x86_64 = mkStatic { arch = "x86_64"; };
static-aarch64 = mkStatic { arch = "aarch64"; };
container-amd64 = containerize packages'.static-x86_64;
container-arm64 = containerize packages'.static-aarch64;
default = packages'.refraction;
}
);
overlays.default = final: _: {
refraction = final.callPackage ./nix/package.nix { };
};
};
}