cooklang-flake/flake.nix

38 lines
1.2 KiB
Nix

{
description = "Cooklang tools";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
pkgsFor = system: import nixpkgs { inherit system; };
perSystem = nixpkgs.lib.genAttrs supportedSystems;
mkApp =
{ drv
, name ? drv.pname or drv.name
, exePath ? drv.passthru.exePath or "bin/${drv.meta.mainProgram or name}"
}: {
type = "app";
program = "${drv}/${exePath}";
};
mkPackage = pkgs: name: pkgs.callPackage ./packages/${name} { };
defaultApp = builtins.head apps; # first app is default one
packages = apps ++ nonApps;
# Apps
apps = [ "cookcli" "cook-docs" ];
# Packages which are not apps
nonApps = [ "cook-mode" ];
in
{
packages = perSystem (system: nixpkgs.lib.genAttrs packages (mkPackage (pkgsFor system)));
apps = perSystem (system:
nixpkgs.lib.genAttrs apps (name: mkApp { drv = self.packages.${system}.${name}; }) // {
default = self.apps.${system}.${defaultApp};
});
overlays = nixpkgs.lib.genAttrs packages (name: final: prev: mkPackage prev name) // {
default = final: prev: nixpkgs.lib.genAttrs packages (mkPackage prev);
};
};
}