-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
118 lines (109 loc) · 3.56 KB
/
Copy pathflake.nix
File metadata and controls
118 lines (109 loc) · 3.56 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
112
113
114
115
116
117
118
{
description = "Yaffle CLI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, rust-overlay, ... }:
let
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version;
forAllSystems = function:
nixpkgs.lib.genAttrs systems (system:
function (import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
}));
in
{
packages = forAllSystems (pkgs:
let
rust = pkgs.rust-bin.stable."1.95.0".minimal.override {
extensions = [ "clippy" "rustfmt" ];
targets = pkgs.lib.optionals pkgs.stdenv.isLinux [ "x86_64-unknown-linux-musl" ];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rust;
rustc = rust;
};
muslCc = pkgs.pkgsCross.musl64.stdenv.cc;
muslLinker = "${muslCc}/bin/${muslCc.targetPrefix}cc";
yaffle = rustPlatform.buildRustPackage ({
pname = "yaffle";
inherit version;
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./Cargo.lock
./Cargo.toml
./crates
./testdata
];
};
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = [ "-p" "yaffle-cli" ];
doCheck = false;
strictDeps = true;
postInstall = ''
$out/bin/yaffle --version
$out/bin/yaffle --help >/dev/null
'';
postFixup = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
install_name_tool -change \
${pkgs.libiconv}/lib/libiconv.2.dylib \
/usr/lib/libiconv.2.dylib \
$out/bin/yaffle
'';
meta = {
description = "Environment orchestration for Terraform and OpenTofu";
homepage = "https://yaffle.dev";
license = pkgs.lib.licenses.mit;
mainProgram = "yaffle";
platforms = systems;
};
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
nativeBuildInputs = [ muslCc ];
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER = muslLinker;
CC_x86_64_unknown_linux_musl = muslLinker;
buildPhase = ''
runHook preBuild
cargo build --offline --release --target x86_64-unknown-linux-musl -p yaffle-cli
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 \
target/x86_64-unknown-linux-musl/release/yaffle \
$out/bin/yaffle
runHook postInstall
'';
});
in
{
inherit yaffle;
default = yaffle;
});
apps = forAllSystems (pkgs: {
default = {
type = "app";
program = "${self.packages.${pkgs.system}.yaffle}/bin/yaffle";
};
yaffle = self.apps.${pkgs.system}.default;
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = [
pkgs.opentofu
pkgs.rust-bin.stable."1.95.0".default
];
};
});
};
}