mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-09-17 09:29:21 +00:00
Merge remote-tracking branch 'upstream/master' into fix-recursive-symlinker
This commit is contained in:
commit
00c8e2fad3
9 changed files with 87 additions and 35 deletions
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
|
@ -63,7 +63,7 @@ pkgs.buildGoApplication {
|
||||||
|
|
||||||
The quickest way to get started if using Nix Flakes is to use the Flake template:
|
The quickest way to get started if using Nix Flakes is to use the Flake template:
|
||||||
``` bash
|
``` bash
|
||||||
$ nix flake init -t github:tweag/gomod2nix#app
|
$ nix flake init -t github:nix-community/gomod2nix#app
|
||||||
```
|
```
|
||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
38
flake.lock
38
flake.lock
|
@ -1,5 +1,23 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694529238,
|
||||||
|
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1658285632,
|
"lastModified": 1658285632,
|
||||||
|
@ -18,22 +36,22 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs",
|
"flake-utils": "flake-utils",
|
||||||
"utils": "utils"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"utils": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1653893745,
|
"lastModified": 1681028828,
|
||||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
"owner": "numtide",
|
"owner": "nix-systems",
|
||||||
"repo": "flake-utils",
|
"repo": "default",
|
||||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "nix-systems",
|
||||||
"repo": "flake-utils",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
flake.nix
35
flake.nix
|
@ -2,10 +2,9 @@
|
||||||
description = "Convert go.mod/go.sum to Nix packages";
|
description = "Convert go.mod/go.sum to Nix packages";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/master";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/master";
|
||||||
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
inputs.utils.url = "github:numtide/flake-utils";
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils }:
|
|
||||||
{
|
{
|
||||||
overlays.default = import ./overlay.nix;
|
overlays.default = import ./overlay.nix;
|
||||||
|
|
||||||
|
@ -18,19 +17,33 @@
|
||||||
defaultTemplate = self.templates.app;
|
defaultTemplate = self.templates.app;
|
||||||
|
|
||||||
} //
|
} //
|
||||||
(utils.lib.eachDefaultSystem
|
(flake-utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
inherit system;
|
|
||||||
overlays = [
|
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
|
||||||
self.overlays.default
|
# This has no effect on other platforms.
|
||||||
];
|
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
|
in
|
||||||
{
|
{
|
||||||
packages.default = pkgs.callPackage ./. { };
|
packages.default = gomod2nix;
|
||||||
devShells.default = import ./shell.nix { inherit pkgs; };
|
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;
|
||||||
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
final: prev:
|
final: prev:
|
||||||
let
|
let
|
||||||
# The newer Darwin SDK does not exist in current (nixos-22.05) stable
|
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
|
||||||
# branches, so just fallback to the default callPackage.
|
# This has no effect on other platforms.
|
||||||
callPackage = final.darwin.apple_sdk_11_0.callPackage or final.callPackage;
|
callPackage = final.darwin.apple_sdk_11_0.callPackage or final.callPackage;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
, gomod2nix ? pkgs.gomod2nix
|
||||||
|
, mkGoEnv ? pkgs.mkGoEnv
|
||||||
}:
|
}:
|
||||||
|
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
|
@ -15,7 +17,7 @@ pkgs.mkShell {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkgs.nixpkgs-fmt
|
pkgs.nixpkgs-fmt
|
||||||
pkgs.golangci-lint
|
pkgs.golangci-lint
|
||||||
pkgs.gomod2nix
|
gomod2nix
|
||||||
(pkgs.mkGoEnv { pwd = ./.; })
|
(mkGoEnv { pwd = ./.; })
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
, buildGoApplication ? pkgs.buildGoApplication
|
||||||
}:
|
}:
|
||||||
|
|
||||||
pkgs.buildGoApplication {
|
buildGoApplication {
|
||||||
pname = "myapp";
|
pname = "myapp";
|
||||||
version = "0.1";
|
version = "0.1";
|
||||||
pwd = ./.;
|
pwd = ./.;
|
||||||
|
|
|
@ -4,20 +4,26 @@
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
|
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
|
||||||
|
inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
|
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
|
||||||
(flake-utils.lib.eachDefaultSystem
|
(flake-utils.lib.eachDefaultSystem
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
inherit system;
|
|
||||||
overlays = [ gomod2nix.overlays.default ];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
|
||||||
|
# This has no effect on other platforms.
|
||||||
|
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.default = pkgs.callPackage ./. { };
|
packages.default = callPackage ./. {
|
||||||
devShells.default = import ./shell.nix { inherit pkgs; };
|
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
|
||||||
|
};
|
||||||
|
devShells.default = callPackage ./shell.nix {
|
||||||
|
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication mkGoEnv gomod2nix;
|
||||||
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,16 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
, mkGoEnv ? pkgs.mkGoEnv
|
||||||
|
, gomod2nix ? pkgs.gomod2nix
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
goEnv = pkgs.mkGoEnv { pwd = ./.; };
|
goEnv = mkGoEnv { pwd = ./.; };
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
goEnv
|
goEnv
|
||||||
pkgs.gomod2nix
|
gomod2nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue