flake: init

flake: use nixpkg unstable for KiCad 9
flake: add KiCad project output script
This commit is contained in:
2025-03-26 10:51:58 +08:00
parent d2cfe3105b
commit d0c0b22e6a
2 changed files with 67 additions and 0 deletions

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1744098102,
"narHash": "sha256-tzCdyIJj9AjysC3OuKA+tMD/kDEDAF9mICPDU7ix0JA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c8cd81426f45942bb2906d5ed2fe21d2f19d95b7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

40
flake.nix Normal file
View File

@@ -0,0 +1,40 @@
{
# unstable for kicad 9.0
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{
nixpkgs,
...
}:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
kicad-project-name = "cxp_sfp";
kicad-main-version = 9;
in
{
formatter.x86_64-linux = pkgs.nixfmt-rfc-style;
devShells.${system}.default = pkgs.mkShell {
name = "kicad-dev-shell";
packages = [
pkgs.kicad
];
};
packages.${system}.default = pkgs.stdenv.mkDerivation {
name = "project-output";
src = ./src;
nativeBuildInputs = [ pkgs.kicad ];
installPhase = ''
# fix "/homeless-shelter cannot be created" error
# see https://github.com/NixOS/nix/issues/670#issuecomment-1211700127
export HOME=$(pwd)
export KICAD${builtins.toString kicad-main-version}_3DMODEL_DIR=${pkgs.kicad.libraries.packages3d}/share/kicad/3dmodels
mkdir -p $out
kicad-cli jobset run ./${kicad-project-name}.kicad_pro -f ./${kicad-project-name}.kicad_jobset
cp -r ./result/* $out
'';
};
};
}