refactor: modify derivation build process

This commit is contained in:
Kiana Sheibani 2025-10-09 22:00:27 -04:00
parent 7562a7a497
commit aadfd1f899
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
2 changed files with 14 additions and 14 deletions

View file

@ -1,22 +1,22 @@
let let
basic-c = name: { stdenv }: basicC = name: { stdenv }:
stdenv.mkDerivation { stdenv.mkDerivation {
inherit name; inherit name;
src = ./.; src = ./.;
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
gcc part2/${name}.c -o ${name} gcc part2/${name}.c -o ${name}.bin
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
install ${name} $out/bin/ install ${name}.bin $out/bin/${name}
runHook postInstall runHook postInstall
''; '';
}; };
in { in {
a1-hello = basic-c "hello"; a1-hello = basicC "hello";
a1-employee = basic-c "employee"; a1-employee = basicC "employee";
a1-logwriter = basic-c "logwriter"; a1-logwriter = basicC "logwriter";
} }

View file

@ -1,26 +1,26 @@
let let
basic-c = subdir: name: { stdenv }: basicC = subdir: name: { stdenv }:
stdenv.mkDerivation { stdenv.mkDerivation {
inherit name; inherit name;
src = ./.; src = ./.;
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
gcc ${subdir}/${name}.c -o ${name} gcc ${subdir}/${name}.c -o ${name}.bin
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
install ${name} $out/bin/ install ${name}.bin $out/bin/${name}
runHook postInstall runHook postInstall
''; '';
}; };
in { in {
a2-p1-producer = basic-c "part1" "producer"; a2-p1-producer = basicC "part1" "producer";
a2-p1-consumer = basic-c "part1" "consumer"; a2-p1-consumer = basicC "part1" "consumer";
a2-p2-bidirectional = basic-c "part2" "bidirectional"; a2-p2-bidirectional = basicC "part2" "bidirectional";
a2-p3-producer = basic-c "part3" "producer"; a2-p3-producer = basicC "part3" "producer";
a2-p3-consumer = basic-c "part3" "consumer"; a2-p3-consumer = basicC "part3" "consumer";
} }