rework flake

This commit is contained in:
Moritz Böhme 2022-12-31 16:26:03 +01:00
parent 012d85c8c2
commit 71e82cca2b
Signed by: moritz
GPG key ID: 970C6E89EB0547A9

View file

@ -9,29 +9,29 @@
mkApp =
{ drv
, name ? drv.pname or drv.name
, exePath ? drv.meta.mainProgram or "bin/${name}"
, exePath ? drv.passthru.exePath or "bin/${drv.meta.mainProgram or name}"
}: {
type = "app";
program = "${drv}/${exePath}";
};
mkPackage = pkgs: name: pkgs.callPackage ./packages/${name}.nix { };
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:
let
pkgs = pkgsFor system;
genPackage = name: pkgs.callPackage ./packages/${name}.nix { };
packages = [ "cookcli" "cook-docs" "cook-mode" ];
in
pkgs.lib.genAttrs packages genPackage // {
default = self.packages.${system}.cookcli;
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};
});
apps = perSystem (system: rec {
cookcli = mkApp {
drv = self.packages.${system}.cookcli;
exePath = "/bin/cook";
};
cook-docs = mkApp { drv = self.packages.${system}.cook-docs; };
default = cookcli;
});
overlays = nixpkgs.lib.genAttrs packages (name: final: prev: mkPackage prev name) // {
default = final: prev: nixpkgs.lib.genAttrs packages (mkPackage prev);
};
};
}