forked from pop-os/distinst
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpackage.nix
156 lines (137 loc) · 4.46 KB
/
package.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{ stdenv
, parted
, pkg-config
, dbus
, rust
, gettext
, lib
, callPackage
, darwin
, llvmPackages
, libxml2
, glib
, libunistring
, writeShellScriptBin
, glibc
, tzdata
, makeWrapper
, nixpkgs
, conf-tool
, makeRustPlatform
, system ? stdenv.targetPlatform.system
, nixFlakes
, drvSrc ? ./.
}:
let
ccForBuild="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
cxxForBuild="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
releaseDir = "target/${rustTarget}/release";
rustTarget = rust.toRustTarget stdenv.hostPlatform;
nixPatched = nixFlakes.overrideAttrs(p: p // {
patches = p.patches ++ [
./json-progress.patch
];
});
tools =
with nixpkgs.lib.nixosSystem {
modules = [
({...}: {
nixpkgs.overlays = [
(self: super: {
nix = nixPatched;
})
];
nix.package = nixPatched;
})
];
inherit system;
};
with config.system.build;
# https://github.com/NixOS/nixpkgs/pull/87182/files?file-filters%5B%5D=.nix&file-filters%5B%5D=.sh&file-filters%5B%5D=.xml
/*
- nix build --out-link "$outLink" --store "$mountPoint" "${extraBuildFlags[@]}" \
+ nix-build --out-link "$outLink" --store "$mountPoint" "${extraBuildFlags[@]}" \
--extra-substituters "$sub" \
- -f '<nixpkgs/nixos>' system -I "nixos-config=$NIXOS_CONFIG" ${verbosity[@]} ${buildLogs}
+ '<nixpkgs/nixos>' -A system -I "nixos-config=$NIXOS_CONFIG" ${verbosity[@]}
*/
[ nixPatched ] ++ [ nixos-generate-config (nixos-install.overrideAttrs(a: a // {
postInstall = ''
sed 's|nix-build|nix build|g' -i $out/bin/nixos-install
sed "s| '<nixpkgs/nixos>' -A system|-f '<nixpkgs/nixos>' system|g" -i $out/bin/nixos-install
'';
})) conf-tool /* nixos-enter manual.manpages */ ] ++
[ (writeShellScriptBin "nixos-install-wrapped" (builtins.readFile ./install-wrapper.sh)) ];
in
with rust; (makeRustPlatform packages.stable).buildRustPackage rec {
inherit tools;
pname = "distinst";
version = "0.0.1";
src = drvSrc;
cargoSha256 = "sha256-9tL5wLwTaiL4jP0BoUgR4fB3HE73XI4y8FT5nE626fw=";
nativeBuildInputs = [
pkg-config
makeWrapper
gettext
];
buildInputs = [
parted
dbus
llvmPackages.clang
llvmPackages.libclang
tzdata
# shadow-deps of gettext rust
libxml2
glib
libunistring
];
preBuild = ''
export LIBCLANG_PATH=${llvmPackages.libclang}/lib
export CFLAGS="$CFLAGS -Wno-error=format-security -Wno-error"
export BINDGEN_EXTRA_CLANG_ARGS="-I${parted.dev}/include -I${glibc.dev}/include -I${llvmPackages.libclang.out}/lib/clang/${llvmPackages.libclang.version}/include" # documented in the code as always... https://github.com/rust-lang/rust-bindgen/pull/1537 # but seems broken due to https://github.com/rust-lang/rust-bindgen/issues/1723
echo 'pub static ZONE_INFO_LOCATION: &str = "${tzdata}/share/zoneinfo";' > crates/timezones/src/buildconfig.rs
'';
buildPhase = with builtins; ''
runHook preBuild
for m in cli ffi; do
(
set -x
env \
"CC_${rust.toRustTarget stdenv.buildPlatform}"="${ccForBuild}" \
"CXX_${rust.toRustTarget stdenv.buildPlatform}"="${cxxForBuild}" \
"CC_${rust.toRustTarget stdenv.hostPlatform}"="${ccForHost}" \
"CXX_${rust.toRustTarget stdenv.hostPlatform}"="${cxxForHost}" \
cargo build \
--release \
--target ${rustTarget} \
--frozen \
--manifest-path $m/Cargo.toml
)
done
# rename the output dir to a architecture independent one
mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep '${releaseDir}$')
for target in "''${targets[@]}"; do
rm -rf "$target/../../release"
ln -srf "$target" "$target/../../"
done
runHook postBuild
'';
shellHook = ''
${preBuild}
export PATH="${lib.makeBinPath tools}:$PATH"
'';
doCheck = false;
installPhase = ''
make VENDORED=1 DEBUG=0 RELEASE=release prefix=$out install
wrapProgram $out/bin/distinst --prefix PATH : ${lib.makeBinPath tools}
'';
meta = with lib; {
description = "An installer backend";
homepage = "https://github.com/pop-os/distinst";
license = licenses.lgpl3;
maintainers = with maintainers; [ mkg20001 ];
platforms = [ "x86_64-linux" ];
};
}