mirror of
https://github.com/tweag/gomod2nix.git
synced 2024-11-08 11:39:11 +00:00
templates: Add a flake template
This commit is contained in:
parent
3ae35c5ce1
commit
d30b3ca30a
9 changed files with 71 additions and 1 deletions
|
@ -5,7 +5,11 @@ buildGoApplication {
|
|||
pname = "gomod2nix";
|
||||
version = "0.1";
|
||||
src = lib.cleanSourceWith {
|
||||
filter = name: type: (! lib.hasSuffix "tests" name) && (! lib.hasSuffix "builder" name);
|
||||
filter = name: type: builtins.foldl' (v: s: v && ! lib.hasSuffix s name) true [
|
||||
"tests"
|
||||
"builder"
|
||||
"templates"
|
||||
];
|
||||
src = lib.cleanSource ./.;
|
||||
};
|
||||
modules = ./gomod2nix.toml;
|
||||
|
|
|
@ -8,6 +8,15 @@
|
|||
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:
|
||||
|
|
1
templates/app/.gitignore
vendored
Normal file
1
templates/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/gomod2nix-template
|
10
templates/app/default.nix
Normal file
10
templates/app/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ buildGoApplication, go, lib }:
|
||||
|
||||
buildGoApplication {
|
||||
inherit go;
|
||||
pname = "myapp";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
modules = ./gomod2nix.toml;
|
||||
subPackages = [ "." ];
|
||||
}
|
23
templates/app/flake.nix
Normal file
23
templates/app/flake.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
description = "A basic gomod2nix flake";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.gomod2nix.url = "github:tweag/gomod2nix";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
|
||||
(flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ gomod2nix.overlays.default ];
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
packages.default = pkgs.callPackage ./. { };
|
||||
devShells.default = import ./shell.nix { inherit pkgs; };
|
||||
})
|
||||
);
|
||||
}
|
3
templates/app/go.mod
Normal file
3
templates/app/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module example.com/gomod2nix-template
|
||||
|
||||
go 1.17
|
3
templates/app/gomod2nix.toml
Normal file
3
templates/app/gomod2nix.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
schema = 1
|
||||
|
||||
[mod]
|
9
templates/app/main.go
Normal file
9
templates/app/main.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello flake")
|
||||
}
|
8
templates/app/shell.nix
Normal file
8
templates/app/shell.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.go
|
||||
pkgs.gomod2nix
|
||||
];
|
||||
}
|
Loading…
Reference in a new issue