74 lines
2 KiB
Nix
74 lines
2 KiB
Nix
{
|
|
description = "the meat (package) manager";
|
|
|
|
inputs = {
|
|
# use registry nixpkgs
|
|
# nixpkgs.url = "nixpkgs/nixos-unstable";
|
|
|
|
src = {
|
|
url = "path:src";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
src,
|
|
}: let
|
|
# System types to support.
|
|
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
|
|
|
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
|
|
# Nixpkgs instantiated for supported system types.
|
|
nixpkgsFor = forAllSystems (system:
|
|
import nixpkgs {
|
|
inherit system;
|
|
# overlays = [self.overlay];
|
|
});
|
|
in {
|
|
# Provide some binary packages for selected system types.
|
|
packages = forAllSystems (system: let
|
|
pkgs = nixpkgsFor.${system};
|
|
in {
|
|
meat = pkgs.callPackage ./meat.nix {
|
|
inherit src;
|
|
};
|
|
});
|
|
|
|
# The default package for 'nix build'. This makes sense if the
|
|
# flake provides only one package or there is a clear "main"
|
|
# package.
|
|
defaultPackage = forAllSystems (system: self.packages.${system}.meat);
|
|
|
|
# A NixOS module, if applicable (e.g. if the package provides a system service).
|
|
nixosModules.meat = {
|
|
pkgs,
|
|
config,
|
|
...
|
|
}: {
|
|
options.programs.meat = with pkgs.lib; {
|
|
flake = mkOption {
|
|
type = with types; nullOr (either path str);
|
|
default = null;
|
|
description = "path to your system flake";
|
|
};
|
|
};
|
|
config = {
|
|
environment.systemPackages = [self.defaultPackage.${pkgs.system}];
|
|
environment.sessionVariables = let
|
|
cfg = config.programs.meat;
|
|
in {
|
|
FLAKE =
|
|
if (cfg.flake == null)
|
|
then throw "Please set the programs.meat.flake option to your system flake."
|
|
else config.programs.meat.flake;
|
|
};
|
|
};
|
|
};
|
|
|
|
# Tests run by 'nix flake check' and by Hydra.
|
|
};
|
|
}
|