Merge remote-tracking branch 'upstream/master' into fix-recursive-symlinker

This commit is contained in:
Niklas Halonen 2023-10-31 15:25:12 +02:00
commit 00c8e2fad3
No known key found for this signature in database
GPG key ID: 7912D083CF630FD3
9 changed files with 87 additions and 35 deletions

10
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

View file

@ -63,7 +63,7 @@ pkgs.buildGoApplication {
The quickest way to get started if using Nix Flakes is to use the Flake template:
``` bash
$ nix flake init -t github:tweag/gomod2nix#app
$ nix flake init -t github:nix-community/gomod2nix#app
```
## Basic usage

View file

@ -1,5 +1,23 @@
{
"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": {
"locked": {
"lastModified": 1658285632,
@ -18,22 +36,22 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"utils": {
"systems": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}

View file

@ -2,10 +2,9 @@
description = "Convert go.mod/go.sum to Nix packages";
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, utils }:
outputs = { self, nixpkgs, flake-utils }:
{
overlays.default = import ./overlay.nix;
@ -18,19 +17,33 @@
defaultTemplate = self.templates.app;
} //
(utils.lib.eachDefaultSystem
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
pkgs = nixpkgs.legacyPackages.${system};
# 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;
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;
};
})
);
}

View file

@ -1,7 +1,7 @@
final: prev:
let
# The newer Darwin SDK does not exist in current (nixos-22.05) stable
# branches, so just fallback to the default callPackage.
# 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 = final.darwin.apple_sdk_11_0.callPackage or final.callPackage;
in
{

View file

@ -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 = ./.; })
];
}

View file

@ -9,9 +9,10 @@
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
}:
pkgs.buildGoApplication {
buildGoApplication {
pname = "myapp";
version = "0.1";
pwd = ./.;

View file

@ -4,20 +4,26 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
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 }:
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ gomod2nix.overlays.default ];
};
pkgs = nixpkgs.legacyPackages.${system};
# 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
{
packages.default = pkgs.callPackage ./. { };
devShells.default = import ./shell.nix { inherit pkgs; };
packages.default = callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};
devShells.default = callPackage ./shell.nix {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication mkGoEnv gomod2nix;
};
})
);
}

View file

@ -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
];
}