flake: cleanup, copper plate is common to both types

This commit is contained in:
Sebastien Bourdeauducq 2023-12-30 11:56:42 +08:00
parent b119e04c73
commit 05ca688af6
1 changed files with 62 additions and 68 deletions

View File

@ -9,17 +9,13 @@
let let
pkgs = import nixpkgs { system = "x86_64-linux"; }; pkgs = import nixpkgs { system = "x86_64-linux"; };
build = { variant }: adapter_production_files = variant: pkgs.stdenv.mkDerivation {
let
adapter_production_files = pkgs.stdenv.mkDerivation {
name = "production-files"; name = "production-files";
src = ./kirdy_LD_adapter_${variant}; src = ./kirdy_LD_adapter_${variant};
nativeBuildInputs = [ pkgs.kicad pkgs.zip pkgs.python3 ]; nativeBuildInputs = [ pkgs.kicad pkgs.zip pkgs.python3 ];
buildPhase = '' buildPhase = ''
echo ${variant}
# kicad-cli requires the use of $HOME # kicad-cli requires the use of $HOME
TMP_DIR="$(mktemp --tmpdir -d kicad-kirdy.XXXXXXX)" TMP_DIR="$(mktemp --tmpdir -d kicad-kirdy.XXXXXXX)"
export HOME=$TMP_DIR export HOME=$TMP_DIR
@ -66,7 +62,7 @@
name = "production-files"; name = "production-files";
src = ./kirdy_LD_adapter_copper_plate; src = ./kirdy_LD_adapter_copper_plate;
nativeBuildInputs = [ pkgs.kicad pkgs.zip pkgs.python3 ]; nativeBuildInputs = [ pkgs.kicad pkgs.python3 ];
buildPhase = '' buildPhase = ''
# kicad-cli requires the use of $HOME # kicad-cli requires the use of $HOME
@ -90,15 +86,13 @@
}; };
in { in {
"LD_adapter_${variant}_PCB" = adapter_production_files;
"LD_adapter_${variant}_copper_plate" = copper_plate_production_files;
};
in rec {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
packages.x86_64-linux = (build { variant = "type_1"; }) packages.x86_64-linux = {
// (build { variant = "type_2"; }); "LD_adapter_type_1_PCB" = adapter_production_files "type_1";
"LD_adapter_type_2_PCB" = adapter_production_files "type_2";
"LD_adapter_copper_plate" = copper_plate_production_files;
};
devShells.x86_64-linux.default = devShells.x86_64-linux.default =
let pkgs = nixpkgs.legacyPackages.x86_64-linux; let pkgs = nixpkgs.legacyPackages.x86_64-linux;