Align flake template with recent API changes and improvements

This commit is contained in:
adisbladis 2022-06-14 17:35:19 +08:00
parent 86ee592eb2
commit 759483247e
3 changed files with 32 additions and 14 deletions

View file

@ -1,14 +1,8 @@
{ pkgs ? ( { pkgs ? (
let let
inherit (builtins) fromJSON readFile; inherit (builtins) fetchTree fromJSON readFile;
flakeLock = fromJSON (readFile ./flake.lock);
locked = flakeLock.nodes.nixpkgs.locked;
nixpkgs = assert locked.type == "github"; builtins.fetchTarball {
url = "https://github.com/${locked.owner}/${locked.repo}/archive/${locked.rev}.tar.gz";
sha256 = locked.narHash;
};
in in
import nixpkgs { import (fetchTree (fromJSON (readFile ./flake.lock)).nodes.nixpkgs.locked) {
overlays = [ overlays = [
(import ./overlay.nix) (import ./overlay.nix)
]; ];

View file

@ -1,10 +1,20 @@
{ buildGoApplication, go, lib }: { pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
}:
buildGoApplication { pkgs.buildGoApplication {
inherit go;
pname = "myapp"; pname = "myapp";
version = "0.1"; version = "0.1";
pwd = ./.;
src = ./.; src = ./.;
modules = ./gomod2nix.toml; modules = ./gomod2nix.toml;
subPackages = [ "." ];
} }

View file

@ -1,8 +1,22 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
}:
let
goEnv = pkgs.mkGoEnv { pwd = ./.; };
in
pkgs.mkShell { pkgs.mkShell {
packages = [ packages = [
pkgs.go goEnv
pkgs.gomod2nix pkgs.gomod2nix
]; ];
} }