diff --git a/.envrc b/.envrc index 3c109b4..88ce07d 100644 --- a/.envrc +++ b/.envrc @@ -4,4 +4,9 @@ if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" fi +export WORKSPACE="${PWD}" + +nix_direnv_watch_file ./shell.nix +nix_direnv_watch_file ./flake.nix + use flake diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..968862f --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,23 @@ +name: Update nix config + +on: + push: + branches: + - main + +jobs: + nix: + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v27 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - run: | + export WORKSPACE="${PWD}" + nix run .#upgrade-nix-gohip + git config --global user.name 'autobot' + git config --global user.email 'gohip.nix@github.com' + git commit -am "[skip ci] Automated nix hash update" + git push diff --git a/flake.nix b/flake.nix index f4e0e9d..a3897cc 100644 --- a/flake.nix +++ b/flake.nix @@ -11,20 +11,29 @@ pkgs = import nixpkgs { inherit system overlays; }; + gohip-vendor-hash = import ./gohip.vendor.hash.nix; gohip-package = (pkgs.buildGoModule { name = "gohip"; pname = "gohip"; src = ./.; - vendorHash = "sha256-jZcR+OMiGplA5yVMpQT4qNKH+tyFp7PXQVoG+oghBLs="; + vendorHash = gohip-vendor-hash pkgs; proxyVendor = true; excludedPackages = ["osdata" "others" "systemd" "types"]; }); + upgrade-nix-gohip-package = pkgs.writeShellScriptBin "upgrade-nix-gohip" '' + echo "UPGRADING" + echo "pkgs : pkgs.lib.fakeHash" > $WORKSPACE/gohip.vendor.hash.nix + NEW_HASH=`nix build .#default 2>&1 | grep " got: " | awk '{print $2}'` + echo "pkgs : \"$NEW_HASH\"" > $WORKSPACE/gohip.vendor.hash.nix + ''; + custom-packages = {upgrade-nix-gohip = upgrade-nix-gohip-package;}; + in with pkgs; { - devShells.default = (import ./shell.nix) pkgs; + devShells.default = (import ./shell.nix) pkgs custom-packages; apps = rec { gohip = flake-utils.lib.mkApp { drv = pkgs.writeShellScriptBin "gohip" '' @@ -32,10 +41,14 @@ "${gohip-package}"/bin/gohip ''; }; + upgrade-nix-gohip = flake-utils.lib.mkApp { + drv = upgrade-nix-gohip-package; + }; default = gohip; }; packages = rec { gohip = gohip-package; + upgrade-nix-gohip = upgrade-nix-gohip-package; default = gohip; }; } diff --git a/gohip.vendor.hash.nix b/gohip.vendor.hash.nix new file mode 100644 index 0000000..9759243 --- /dev/null +++ b/gohip.vendor.hash.nix @@ -0,0 +1 @@ +pkgs : "sha256-6+n1rLcpWI553EUl98UVRCu/nK8+dw9cLJqmpA3LTsw=" diff --git a/shell.nix b/shell.nix index 3c3f160..99d2a7f 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,7 @@ -pkgs : +pkgs : custom-packages : -pkgs.mkShell { - buildInputs = [ pkgs.go ]; -} +let +in + pkgs.mkShell { + buildInputs = [ pkgs.go custom-packages.upgrade-nix-gohip ]; + }