Skip to content

Commit

Permalink
chore: update nix flake to remove deprecation warning (#113)
Browse files Browse the repository at this point in the history
* chore: update nix flake to remove deprecation warning

* feat: update-nix script changes

---------

Co-authored-by: joerdav <[email protected]>
  • Loading branch information
a-h and joerdav committed Feb 27, 2024
1 parent aaef84a commit 67d4117
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage.out
dist/
doc/public/

coverage.out
result
12 changes: 7 additions & 5 deletions flake.lock

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

8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/23.11";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
let
pkgs = import nixpkgs {
system = system;
};
xc = pkgs.callPackage ./xc.nix {};
xc = pkgs.callPackage ./xc.nix { };
in
{
defaultPackage = xc;
packages = {
packages = {
xc = xc;
};
devShells = {
Expand Down
4 changes: 2 additions & 2 deletions update-nix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ sed -e "s/__VERSION__/$(git describe --tags --abbrev=0)/g" xc.nix.tmpl > xc.nix
# We first try to build and it fails with hash mismatch, and we use it to populate sha256.
nix-build -E 'with import <nixpkgs> { }; callPackage ./xc.nix { }'
SRC_SHA256="$(nix-build -E 'with import <nixpkgs> { }; callPackage ./xc.nix { }' 2>&1 | grep -oE 'got:\s+sha256-\S+' | cut -d "-" -f 2)"
sed -i -e "s|sha256 = lib.fakeSha256;|sha256 = \"$SRC_SHA256\";|g" xc.nix
sed -i -e "s|sha256 = \"\";|sha256 = \"$SRC_SHA256\";|g" xc.nix

# We try again to build and it fails with hash mismatch, and we use it to populate vendorSha256.
VENDOR_SHA256="$(nix-build -E 'with import <nixpkgs> { }; callPackage ./xc.nix { }' 2>&1 | grep -oE 'got:\s+sha256-\S+' | cut -d "-" -f 2)"
sed -i -e "s|vendorSha256 = lib.fakeSha256;|vendorSha256 = \"$VENDOR_SHA256\";|g" xc.nix
sed -i -e "s|vendorHash = \"\";|vendorHash = \"sha256-$VENDOR_SHA256\";|g" xc.nix

6 changes: 3 additions & 3 deletions xc.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{ config, lib, pkgs, fetchFromGitHub, ... }:
{ config, pkgs, fetchFromGitHub, ... }:

pkgs.buildGoModule rec {
pname = "xc";
version = "v0.8.0";
subPackages = ["cmd/xc"];
subPackages = [ "cmd/xc" ];
src = pkgs.fetchFromGitHub {
owner = "joerdav";
repo = "xc";
rev = version;
sha256 = "vTyCS85xbJnAgbasWD6LFxij9EezzlJ1pyvCJptqmOU=";
};
vendorSha256 = "EbIuktQ2rExa2DawyCamTrKRC1yXXMleRB8/pcKFY5c=";
vendorHash = "sha256-EbIuktQ2rExa2DawyCamTrKRC1yXXMleRB8/pcKFY5c=";
}
8 changes: 4 additions & 4 deletions xc.nix.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{ config, lib, pkgs, fetchFromGitHub, ... }:
{ config, pkgs, fetchFromGitHub, ... }:

pkgs.buildGoModule rec {
pname = "xc";
version = "__VERSION__";
subPackages = ["cmd/xc"];
subPackages = [ "cmd/xc" ];
src = pkgs.fetchFromGitHub {
owner = "joerdav";
repo = "xc";
rev = version;
sha256 = lib.fakeSha256;
sha256 = "";
};
vendorSha256 = lib.fakeSha256;
vendorHash = "";
}

0 comments on commit 67d4117

Please sign in to comment.