Skip to content

Commit

Permalink
build(nix): update flake
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Apr 1, 2024
1 parent 19f864b commit a5cccef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
11 changes: 11 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,14 @@ tasks:
- git tag {{.NEXT}}
- echo {{.NEXT}}
- git push origin --tags

nix:flake:update-vendor:
desc: update default flake package vendor hash
cmds:
- bash ./scripts/nix-update-flake.sh
generates:
- flake.nix
sources:
- flake.lock
- go.mod
- go.sum
31 changes: 7 additions & 24 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
staging.url = "github:caarlos0/nixpkgs/wip";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, staging, flake-utils, ... }:
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
staging-pkgs = staging.legacyPackages.${system};
in
{
packages.default = pkgs.buildGoModule {
Expand All @@ -17,14 +15,15 @@
src = ./.;
ldflags = [ "-s" "-w" "-X main.version=dev" "-X main.builtBy=flake" ];
doCheck = false;
vendorHash = "sha256-P9jSQG6EyVGMZKtThy8Q7Y/pV7mbMl2eGrylea0VHRc=";
vendorHash = "sha256-g57tLk2+WWcdG0COqkQD7eLYG0TdC0RnlhLF6Qt4woY=";
};

devShells.default = pkgs.mkShell {
packages = with pkgs; [
go
go-task
gofumpt
nix-prefetch
];
shellHook = "go mod tidy";
};
Expand Down
6 changes: 6 additions & 0 deletions scripts/nix-update-flake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
NEW_HASH="$(nix-prefetch \
--option extra-experimental-features flakes \
'{ sha256 }: (builtins.getFlake (toString ./.)).packages.x86_64-linux.default.goModules.overrideAttrs (_: { vendorSha256 = sha256; })')"

sed -i "s|vendorHash = \".*\"|vendorHash = \"${NEW_HASH}\"|" ./flake.nix

0 comments on commit a5cccef

Please sign in to comment.