diff --git a/flake.nix b/flake.nix index 85ee185..aa052e5 100644 --- a/flake.nix +++ b/flake.nix @@ -21,16 +21,30 @@ (utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ - self.overlays.default - ]; + 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 = pkgs.callPackage ./. { }; - devShells.default = import ./shell.nix { inherit pkgs; }; + 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; + }; }) ); } diff --git a/shell.nix b/shell.nix index f80d988..f6229c6 100644 --- a/shell.nix +++ b/shell.nix @@ -8,6 +8,8 @@ ]; } ) +, gomod2nix ? pkgs.gomod2nix +, mkGoEnv ? pkgs.mkGoEnv }: pkgs.mkShell { @@ -15,7 +17,7 @@ pkgs.mkShell { nativeBuildInputs = [ pkgs.nixpkgs-fmt pkgs.golangci-lint - pkgs.gomod2nix - (pkgs.mkGoEnv { pwd = ./.; }) + gomod2nix + (mkGoEnv { pwd = ./.; }) ]; } diff --git a/templates/app/default.nix b/templates/app/default.nix index 2c29bbc..14ec4fe 100644 --- a/templates/app/default.nix +++ b/templates/app/default.nix @@ -9,9 +9,10 @@ ]; } ) +, buildGoApplication ? pkgs.buildGoApplication }: -pkgs.buildGoApplication { +buildGoApplication { pname = "myapp"; version = "0.1"; pwd = ./.; diff --git a/templates/app/flake.nix b/templates/app/flake.nix index 824ce7d..1238c4e 100644 --- a/templates/app/flake.nix +++ b/templates/app/flake.nix @@ -9,15 +9,15 @@ (flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ gomod2nix.overlays.default ]; - }; - + pkgs = nixpkgs.legacyPackages.${system}; in { - packages.default = pkgs.callPackage ./. { }; - devShells.default = import ./shell.nix { inherit pkgs; }; + packages.default = pkgs.callPackage ./. { + inherit (gomod2nix.legacyPackages.${system}) buildGoApplication; + }; + devShells.default = pkgs.callPackage ./shell.nix { + inherit (gomod2nix.legacyPackages.${system}) buildGoApplication mkGoEnv gomod2nix; + }; }) ); } diff --git a/templates/app/shell.nix b/templates/app/shell.nix index b8e49a9..d4f21a8 100644 --- a/templates/app/shell.nix +++ b/templates/app/shell.nix @@ -9,14 +9,16 @@ ]; } ) +, mkGoEnv ? pkgs.mkGoEnv +, gomod2nix ? pkgs.gomod2nix }: let - goEnv = pkgs.mkGoEnv { pwd = ./.; }; + goEnv = mkGoEnv { pwd = ./.; }; in pkgs.mkShell { packages = [ goEnv - pkgs.gomod2nix + gomod2nix ]; }