From e6db88d07115559a062cf195464b833ccd8b3d09 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Tue, 6 Sep 2022 13:49:01 -0600 Subject: [PATCH 1/2] test template --- flake.nix | 5 +++++ templates/go/.envrc | 1 + templates/go/flake.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 templates/go/.envrc create mode 100644 templates/go/flake.nix diff --git a/flake.nix b/flake.nix index 70ab4ca..e248343 100644 --- a/flake.nix +++ b/flake.nix @@ -163,5 +163,10 @@ ]; }; }; + + templates."go" = { + path = ./templates/go; + description = "Go template."; + }; }; } diff --git a/templates/go/.envrc b/templates/go/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/go/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/go/flake.nix b/templates/go/flake.nix new file mode 100644 index 0000000..6910571 --- /dev/null +++ b/templates/go/flake.nix @@ -0,0 +1,42 @@ +{ + description = "thing: stuff and things"; + + inputs.nixpkgs.url = "nixpkgs/nixos-21.11"; + + outputs = { self, nixpkgs }: + let + lastModifiedDate = + self.lastModifiedDate or self.lastModified or "19700101"; + version = builtins.substring 0 8 lastModifiedDate; + supportedSystems = + [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in { + packages = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in { + thing = pkgs.buildGoModule { + pname = "thing"; + inherit version; + src = ./.; + + vendorSha256 = pkgs.lib.fakeSha256; + proxyVendor = true; + }; + }); + + defaultPackage = forAllSystems (system: self.packages.${system}.pnix); + devShells = forAllSystems (system: + let pkgs = nixpkgsFor.${system}; + in { + default = pkgs.mkShell { + shellHook = '' + PS1='\u@\h:\@; ' + ''; + nativeBuildInputs = with pkgs; [ git go gopls go-tools ]; + }; + }); + }; +} + From dbf01143fd0a7beea58ec1bc042301b1fd0b5f96 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Tue, 6 Sep 2022 17:59:05 -0600 Subject: [PATCH 2/2] use an easier to set template --- templates/go/flake.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/templates/go/flake.nix b/templates/go/flake.nix index 6910571..387792f 100644 --- a/templates/go/flake.nix +++ b/templates/go/flake.nix @@ -5,9 +5,6 @@ outputs = { self, nixpkgs }: let - lastModifiedDate = - self.lastModifiedDate or self.lastModified or "19700101"; - version = builtins.substring 0 8 lastModifiedDate; supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; @@ -18,7 +15,7 @@ in { thing = pkgs.buildGoModule { pname = "thing"; - inherit version; + version = "v0.0.0"; src = ./.; vendorSha256 = pkgs.lib.fakeSha256; @@ -33,6 +30,7 @@ default = pkgs.mkShell { shellHook = '' PS1='\u@\h:\@; ' + echo "Go `${pkgs.go}/bin/go version`" ''; nativeBuildInputs = with pkgs; [ git go gopls go-tools ]; };