From a5cccefbf341573f48b54abca1f0fbd89423a60c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 1 Apr 2024 11:06:02 -0300 Subject: [PATCH] build(nix): update flake --- Taskfile.yml | 11 +++++++++++ flake.lock | 31 +++++++------------------------ flake.nix | 7 +++---- scripts/nix-update-flake.sh | 6 ++++++ 4 files changed, 27 insertions(+), 28 deletions(-) create mode 100755 scripts/nix-update-flake.sh diff --git a/Taskfile.yml b/Taskfile.yml index a1679dbf..1a634af0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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 diff --git a/flake.lock b/flake.lock index 14efb3c1..491e53f7 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1703438236, - "narHash": "sha256-aqVBq1u09yFhL7bj1/xyUeJjzr92fXVvQSSEx6AdB1M=", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5f64a12a728902226210bf01d25ec6cbb9d9265b", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", "type": "github" }, "original": { @@ -37,24 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "staging": "staging" - } - }, - "staging": { - "locked": { - "lastModified": 1703777495, - "narHash": "sha256-ISkNWa58+6Uk/nQ47omTETrV+yhKFbnU/wR9n+3ux8g=", - "owner": "caarlos0", - "repo": "nixpkgs", - "rev": "e1d1738a056a052aedb6560c240b2749af33fee0", - "type": "github" - }, - "original": { - "owner": "caarlos0", - "ref": "wip", - "repo": "nixpkgs", - "type": "github" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index a4bce48c..bb621920 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { @@ -17,7 +15,7 @@ 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 { @@ -25,6 +23,7 @@ go go-task gofumpt + nix-prefetch ]; shellHook = "go mod tidy"; }; diff --git a/scripts/nix-update-flake.sh b/scripts/nix-update-flake.sh new file mode 100755 index 00000000..5f4b9113 --- /dev/null +++ b/scripts/nix-update-flake.sh @@ -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