-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
106 lines (97 loc) · 2.68 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
rec {
description = "`nix2sbom` extracts the SBOM (Software Bill of Materials) from a Nix derivation";
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
fenix,
naersk,
}: (
flake-utils.lib.eachDefaultSystem
(
system: (
let
authorName = "louib";
mainBranch = "main";
authorEmail = "[email protected]";
projectName = "nix2sbom";
targetMuslSystem = "x86_64-unknown-linux-musl";
pkgs = import nixpkgs {
inherit system;
};
cargoPackages = with pkgs; [
cargo
rustc
rustfmt
rust-analyzer
];
# Defining our fenix-based Rust toolchain.
fenixPkgs = fenix.packages.${system};
toolchain = fenixPkgs.combine [
fenixPkgs.minimal.cargo
fenixPkgs.minimal.rustc
fenixPkgs.targets.${targetMuslSystem}.latest.rust-std
];
crossPkgs = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};
in {
devShells = {
default = pkgs.mkShell {
buildInputs = cargoPackages;
shellHook = ''
'';
};
# The musl shell is used to produce the statically-compiled binary.
# It has only been tested on x86_64-linux systems.
musl = pkgs.mkShell {
buildInputs = [toolchain];
shellHook = ''
export CARGO_BUILD_TARGET="${targetMuslSystem}"
'';
};
};
packages = {
default = pkgs.rustPlatform.buildRustPackage {
pname = projectName;
version = mainBranch;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
meta = with pkgs.lib; {
inherit description;
homepage = "https://github.com/${authorName}/${projectName}";
license = licenses.gpl3;
maintainers = [
{
name = authorName;
github = authorName;
email = authorEmail;
}
];
};
};
};
}
)
)
);
}