-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
111 lines (102 loc) · 2.88 KB
/
flake.nix
File metadata and controls
111 lines (102 loc) · 2.88 KB
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
{
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable";
inputs.fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nix-filter = {
url = "github:numtide/nix-filter";
};
outputs = {
self,
nixpkgs,
fenix,
nix-filter,
...
} @ inputs: let
packageName = "cmjava";
forSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
] (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
${packageName} = self.packages.${system}.${packageName};
})
];
};
fenix-pkgs = fenix.packages.${system};
fenix-channel = fenix-pkgs.toolchainOf {
channel = "nightly";
date = builtins.replaceStrings ["nightly-"] [""] (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain.channel;
sha256 = "sha256-SzEeSoO54GiBQ2kfANPhWrt0EDRxqEvhIbTt2uJt/TQ=";
};
in
function {inherit system pkgs fenix-pkgs fenix-channel;});
in {
formatter = forSystems ({pkgs, ...}: pkgs.alejandra);
packages = forSystems ({
pkgs,
fenix-channel,
fenix-pkgs,
system,
...
}: {
${packageName} = pkgs.callPackage (./. + "/nix/packages/${packageName}.nix") {
inherit packageName;
flake-self = self;
nix-filter = import inputs.nix-filter;
rustPlatform = pkgs.makeRustPlatform {
cargo = fenix-channel.toolchain;
rustc = fenix-channel.toolchain;
};
};
default = self.packages.${system}.${packageName};
"${packageName}-static" = let
pkgsCross = pkgs.pkgsStatic;
toolchain = with fenix-pkgs;
combine [
minimal.cargo
minimal.rustc
targets.${pkgsCross.rust.lib.toRustTarget pkgsCross.stdenv.targetPlatform}.latest.rust-std
];
in
pkgsCross.callPackage (./. + "/nix/packages/${packageName}.nix") {
inherit packageName;
flake-self = self;
nix-filter = import nix-filter;
rustPlatform = pkgsCross.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
};
});
devShells = forSystems ({
pkgs,
fenix-pkgs,
fenix-channel,
...
}: let
fenixRustToolchain = fenix-channel.withComponents [
"cargo"
"clippy-preview"
"rust-src"
"rustc"
"rustfmt-preview"
];
in {
default = pkgs.callPackage (./. + "/nix/dev-shells/${packageName}.nix") {
inherit fenixRustToolchain packageName;
};
ci = pkgs.callPackage ./nix/dev-shells/ci.nix {
inherit fenixRustToolchain packageName;
};
});
};
}