mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-11-04 17:49:08 +00:00
cf42f710c1
As creator of small tools, my flakes might often end up in other peoples projects. Overlays are a performance problem in those use cases because I would kept re-instantiating nixpkgs instances. Of course I could also expose my stuff as overlays as well. In that case I would need to merge downstream dependencies like go2modnix as well, which would polute their nixpkgs instance with unrelated stuff and also make it harder for my users to tell what random attributes came from which place.
50 lines
1.4 KiB
Nix
50 lines
1.4 KiB
Nix
{
|
|
description = "Convert go.mod/go.sum to Nix packages";
|
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/master";
|
|
|
|
inputs.utils.url = "github:numtide/flake-utils";
|
|
|
|
outputs = { self, nixpkgs, utils }:
|
|
{
|
|
overlays.default = import ./overlay.nix;
|
|
|
|
templates = {
|
|
app = {
|
|
path = ./templates/app;
|
|
description = "Gomod2nix packaged application";
|
|
};
|
|
};
|
|
defaultTemplate = self.templates.app;
|
|
|
|
} //
|
|
(utils.lib.eachDefaultSystem
|
|
(system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
# The newer Darwin SDK does not exist in current (nixos-22.05) stable
|
|
# branches, so just fallback to the default callPackage.
|
|
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
|
|
|
inherit (callPackage ./builder {
|
|
inherit gomod2nix;
|
|
}) mkGoEnv buildGoApplication;
|
|
gomod2nix = callPackage ./default.nix {
|
|
inherit mkGoEnv buildGoApplication;
|
|
};
|
|
in
|
|
{
|
|
packages.default = gomod2nix;
|
|
legacyPackages = {
|
|
# we cannot put them in packages because they are builder functions
|
|
inherit mkGoEnv buildGoApplication;
|
|
# just have this here for convenience
|
|
inherit gomod2nix;
|
|
};
|
|
devShells.default = callPackage ./shell.nix {
|
|
inherit mkGoEnv gomod2nix;
|
|
};
|
|
})
|
|
);
|
|
}
|