kicad: add srcs parameter to allow configuring kicad versions
This also exposes the full src and version parameters for each derivation, allowing them to overrideable by srcs.
This commit is contained in:
parent
9d13164b27
commit
f2cb2c447d
@ -20,11 +20,13 @@
|
||||
, libXdmcp
|
||||
, fetchpatch
|
||||
, lndir
|
||||
, callPackages
|
||||
, callPackage
|
||||
|
||||
, stable
|
||||
, baseName
|
||||
, versions
|
||||
, kicadSrc
|
||||
, kicadVersion
|
||||
, i18n
|
||||
, withOCE
|
||||
, opencascade
|
||||
, withOCC
|
||||
@ -45,28 +47,13 @@ assert stdenv.lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails
|
||||
assert stdenv.lib.asserts.assertMsg (!(withOCC && withOCE))
|
||||
"Only one of OCC and OCE may be enabled";
|
||||
let
|
||||
versionConfig = versions.${baseName};
|
||||
|
||||
libraries = callPackages ./libraries.nix versionConfig.libVersion;
|
||||
|
||||
inherit (stdenv.lib) optional optionals;
|
||||
versionConfig = versions.${baseName};
|
||||
libraries = callPackages ./libraries.nix versionConfig.libVersion;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
|
||||
i18n = libraries.i18n;
|
||||
|
||||
pname = "kicad-base";
|
||||
version = "${builtins.substring 0 10 versions.${baseName}.kicadVersion.src.rev}";
|
||||
version = kicadVersion;
|
||||
|
||||
src = fetchFromGitLab (
|
||||
{
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad";
|
||||
} // versionConfig.kicadVersion.src
|
||||
);
|
||||
src = kicadSrc;
|
||||
|
||||
# quick fix for #72248
|
||||
# should be removed if a a more permanent fix is published
|
||||
|
@ -30,8 +30,45 @@
|
||||
, valgrind
|
||||
, with3d ? true
|
||||
, withI18n ? true
|
||||
, srcs ? { }
|
||||
}:
|
||||
|
||||
# The `srcs` parameter can be used to override the kicad source code
|
||||
# and all libraries (including i18n), which are otherwise inaccessible
|
||||
# to overlays since most of the kicad build expression has been
|
||||
# refactored into base.nix, most of the library build expressions have
|
||||
# been refactored into libraries.nix, and most the i18n build
|
||||
# expression has been refactored into i18n.nix. Overrides are only
|
||||
# applied when building `kicad-unstable`. The `srcs` parameter has no
|
||||
# effect for stable `kicad`. `srcs` takes an attribute set in which
|
||||
# any of the following attributes are meaningful (though none are
|
||||
# mandatory): "kicad", "kicadVersion", "i18n", "symbols", "templates",
|
||||
# "footprints", "packages3d", and "libVersion". "kicadVersion" and
|
||||
# "libVersion" should be set to a string with the desired value for
|
||||
# the version attribute in kicad's `mkDerivation` and the version
|
||||
# attribute in any of the library's or i18n's `mkDerivation`,
|
||||
# respectively. "kicad", "i18n", "symbols", "templates", "footprints",
|
||||
# and "packages3d" should be set to an appropriate fetcher (e.g.,
|
||||
# `fetchFromGitLab`). So, for example, a possible overlay for kicad
|
||||
# is:
|
||||
#
|
||||
# final: prev:
|
||||
|
||||
# {
|
||||
# kicad-unstable = (prev.kicad-unstable.override {
|
||||
# srcs = {
|
||||
# kicadVersion = "2020-10-08";
|
||||
# kicad = prev.fetchFromGitLab {
|
||||
# group = "kicad";
|
||||
# owner = "code";
|
||||
# repo = "kicad";
|
||||
# rev = "fd22fe8e374ce71d57e9f683ba996651aa69fa4e";
|
||||
# sha256 = "sha256-F8qugru/jU3DgZSpQXQhRGNFSk0ybFRkpyWb7HAGBdc=";
|
||||
# };
|
||||
# };
|
||||
# });
|
||||
# }
|
||||
|
||||
assert withNgspice -> libngspice != null;
|
||||
assert stdenv.lib.assertMsg (!ngspiceSupport)
|
||||
"`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments.";
|
||||
@ -43,9 +80,58 @@ assert stdenv.lib.assertMsg (!withOCCT)
|
||||
"`withOCCT` was renamed to `withOCC` for the sake of consistency with upstream cmake options.";
|
||||
let
|
||||
baseName = if (stable) then "kicad" else "kicad-unstable";
|
||||
versionsImport = import ./versions.nix;
|
||||
|
||||
versions = import ./versions.nix;
|
||||
versionConfig = versions.${baseName};
|
||||
# versions.nix does not provide us with version, src and rev. We
|
||||
# need to turn this into approprate fetcher calls.
|
||||
kicadSrcFetch = fetchFromGitLab {
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad";
|
||||
rev = versionsImport.${baseName}.kicadVersion.src.rev;
|
||||
sha256 = versionsImport.${baseName}.kicadVersion.src.sha256;
|
||||
};
|
||||
|
||||
i18nSrcFetch = fetchFromGitLab {
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad-i18n";
|
||||
rev = versionsImport.${baseName}.libVersion.libSources.i18n.rev;
|
||||
sha256 = versionsImport.${baseName}.libVersion.libSources.i18n.sha256;
|
||||
};
|
||||
|
||||
libSrcFetch = name: fetchFromGitLab {
|
||||
group = "kicad";
|
||||
owner = "libraries";
|
||||
repo = "kicad-${name}";
|
||||
rev = versionsImport.${baseName}.libVersion.libSources.${name}.rev;
|
||||
sha256 = versionsImport.${baseName}.libVersion.libSources.${name}.sha256;
|
||||
};
|
||||
|
||||
# only override `src` or `version` if building `kicad-unstable` with
|
||||
# the appropriate attribute defined in `srcs`.
|
||||
srcOverridep = attr: (!stable && builtins.hasAttr attr srcs);
|
||||
|
||||
# use default source and version (as defined in versions.nix) by
|
||||
# default, or use the appropriate attribute from `srcs` if building
|
||||
# unstable with `srcs` properly defined.
|
||||
kicadSrc =
|
||||
if srcOverridep "kicad" then srcs.kicad
|
||||
else kicadSrcFetch;
|
||||
kicadVersion =
|
||||
if srcOverridep "kicadVersion" then srcs.kicadVersion
|
||||
else versionsImport.${baseName}.kicadVersion.version;
|
||||
|
||||
i18nSrc = if srcOverridep "i18n" then srcs.i18n else i18nSrcFetch;
|
||||
i18nVersion =
|
||||
if srcOverridep "i18nVersion" then srcs.i18nVersion
|
||||
else versionsImport.${baseName}.libVersion.version;
|
||||
|
||||
libSrc = name: if srcOverridep name then srcs.${name} else libSrcFetch name;
|
||||
# TODO does it make sense to only have one version for all libs?
|
||||
libVersion =
|
||||
if srcOverridep "libVersion" then srcs.libVersion
|
||||
else versionsImport.${baseName}.libVersion.version;
|
||||
|
||||
wxGTK =
|
||||
if (stable)
|
||||
@ -69,15 +155,22 @@ let
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
|
||||
passthru.libraries = callPackages ./libraries.nix versionConfig.libVersion;
|
||||
# Common libraries, referenced during runtime, via the wrapper.
|
||||
passthru.libraries = callPackages ./libraries.nix { inherit libSrc libVersion; };
|
||||
passthru.i18n = callPackage ./i18n.nix {
|
||||
src = i18nSrc;
|
||||
version = i18nVersion;
|
||||
};
|
||||
base = callPackage ./base.nix {
|
||||
inherit versions stable baseName;
|
||||
inherit stable baseName;
|
||||
inherit kicadSrc kicadVersion;
|
||||
inherit (passthru) i18n;
|
||||
inherit wxGTK python wxPython;
|
||||
inherit debug withI18n withOCC withOCE withNgspice withScripting;
|
||||
};
|
||||
|
||||
inherit pname;
|
||||
version = versions.${baseName}.kicadVersion.version;
|
||||
version = kicadVersion;
|
||||
|
||||
src = base;
|
||||
dontUnpack = true;
|
||||
|
18
pkgs/applications/science/electronics/kicad/i18n.nix
Normal file
18
pkgs/applications/science/electronics/kicad/i18n.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{ stdenv
|
||||
, cmake
|
||||
, gettext
|
||||
, src
|
||||
, version
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
inherit src version;
|
||||
|
||||
pname = "kicad-i18n";
|
||||
|
||||
nativeBuildInputs = [ cmake gettext ];
|
||||
meta = with stdenv.lib; {
|
||||
license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
@ -1,34 +1,17 @@
|
||||
{ stdenv
|
||||
, cmake
|
||||
, gettext
|
||||
, fetchFromGitHub
|
||||
, fetchFromGitLab
|
||||
, version
|
||||
, libSources
|
||||
, libSrc
|
||||
, libVersion
|
||||
}:
|
||||
|
||||
# callPackage libraries {
|
||||
# version = "unstable";
|
||||
# libs.symbols = {
|
||||
# rev = "09f9..";
|
||||
# sha256 = "...";
|
||||
# };
|
||||
# };
|
||||
let
|
||||
mkLib = name:
|
||||
stdenv.mkDerivation {
|
||||
pname = "kicad-${name}";
|
||||
# Use the revision instead of `version` (which is an ISO 8601 date)
|
||||
# to prevent duplicating the library when just the date changed
|
||||
version = "${builtins.substring 0 10 libSources.${name}.rev}";
|
||||
src = fetchFromGitHub (
|
||||
{
|
||||
owner = "KiCad";
|
||||
repo = "kicad-${name}";
|
||||
rev = version;
|
||||
inherit name;
|
||||
} // (libSources.${name} or { })
|
||||
);
|
||||
version = libVersion;
|
||||
|
||||
src = libSrc name;
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
meta = rec {
|
||||
@ -45,30 +28,4 @@ in
|
||||
templates = mkLib "templates";
|
||||
footprints = mkLib "footprints";
|
||||
packages3d = mkLib "packages3d";
|
||||
|
||||
# i18n is a special case, not actually a library
|
||||
# more a part of kicad proper, but also optional and separate
|
||||
# since their move to gitlab they're keeping it in a separate path
|
||||
# kicad has no way to find i18n except through a path relative to its install path
|
||||
# therefore this is being linked into ${kicad-base}/share/
|
||||
# and defined here to make use of the rev & sha256's brought here for the libs
|
||||
i18n = let name = "i18n"; in
|
||||
stdenv.mkDerivation {
|
||||
pname = "kicad-${name}";
|
||||
version = "${builtins.substring 0 10 libSources.${name}.rev}";
|
||||
src = fetchFromGitLab (
|
||||
{
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad-${name}";
|
||||
rev = version;
|
||||
inherit name;
|
||||
} // (libSources.${name} or { })
|
||||
);
|
||||
nativeBuildInputs = [ cmake gettext ];
|
||||
meta = {
|
||||
license = stdenv.lib.licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user