tools/flake.nix

85 lines
2.6 KiB
Nix
Raw Normal View History

2022-11-25 00:13:47 +03:00
{
inputs = {
2023-03-22 14:13:36 +03:00
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
2023-03-22 14:13:36 +03:00
poetry2nix.url = "github:nix-community/poetry2nix";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
poetry2nix.inputs.flake-utils.follows = "flake-utils";
wd2.url = "git+https://git.pleshevski.ru/pleshevskiy/wd2";
wd2.inputs.nixpkgs.follows = "nixpkgs";
wd2.inputs.flake-utils.follows = "flake-utils";
2023-04-05 13:42:33 +03:00
nixpkgs_volar.url = "github:ehllie/nixpkgs/volar";
2022-11-25 00:13:47 +03:00
};
outputs = { nixpkgs, flake-utils, poetry2nix, ... } @ inputs:
2022-11-25 00:13:47 +03:00
let
inherit (builtins) listToAttrs mapAttrs;
2023-04-05 13:42:33 +03:00
allPackageNames = [ "d2" "d2plugin-tala" "d2full" "wd2" "fawltydeps" "volar" ];
2022-12-13 17:21:48 +03:00
mkAllPackages = pkgs':
let
d2-unwrapped = pkgs'.callPackage ./pkgs/d2/d2-unwrapped.nix { };
d2plugin-tala = pkgs'.callPackage ./pkgs/d2/d2plugin-tala.nix { };
d2 = pkgs'.callPackage ./pkgs/d2 {
inherit d2-unwrapped d2plugin-tala;
};
in
{
2023-04-05 13:42:33 +03:00
inherit d2 d2plugin-tala;
2023-01-04 06:40:23 +03:00
d2-full = d2.override { withTala = true; };
2023-04-05 13:42:33 +03:00
wd2 = pkgs'.callPackage "${inputs.wd2}/wd2.nix" { inherit d2; };
fawltydeps = pkgs'.callPackage ./pkgs/fawltydeps { };
# Temporary workaround to use volar language server for vue
#
# Remove when the following PR will be merged
# https://github.com/NixOS/nixpkgs/pull/190921
volar = inputs.nixpkgs_volar.legacyPackages.${pkgs'.system}.nodePackages.volar;
2022-12-13 17:21:48 +03:00
};
2023-04-05 13:42:33 +03:00
mkApp = drv:
let
inherit (builtins) head split;
pname = head (split "-" drv.name);
in
flake-utils.lib.mkApp
{
inherit drv;
name = if pname == "volar" then "vue-language-server" else pname;
};
2022-11-25 00:13:47 +03:00
mkOverlay = name:
final: prev:
2023-03-22 14:13:36 +03:00
final.filterAttrs (n: v: n == name) (mkAllPackages prev)
2023-03-27 10:23:22 +03:00
// { poetry2nix = nixpkgs.legacyPackages.${final.system}.poetry2nix; };
2022-11-25 00:13:47 +03:00
in
{
overlays = (listToAttrs
(map
(name: { inherit name; value = mkOverlay name; })
allPackageNames
)
) // {
2023-03-22 14:13:36 +03:00
all = final: prev:
mkAllPackages prev
2023-03-27 10:23:22 +03:00
// { poetry2nix = nixpkgs.legacyPackages.${final.system}.poetry2nix; };
2022-11-25 00:13:47 +03:00
};
}
// flake-utils.lib.eachDefaultSystem (system:
let
2023-03-22 14:13:36 +03:00
overlays = [ poetry2nix.overlay ];
pkgs = import nixpkgs { inherit system overlays; };
2022-12-13 17:21:48 +03:00
packages = mkAllPackages pkgs;
2022-11-25 00:13:47 +03:00
in
{
check = packages;
inherit packages;
apps = mapAttrs (name: mkApp) packages;
});
}