Skip to content

Commit

Permalink
Use globset to specify src for nix-snapshotter
Browse files Browse the repository at this point in the history
  • Loading branch information
elpdt852 committed Oct 26, 2024
1 parent f295782 commit a4dffdc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
21 changes: 21 additions & 0 deletions flake.lock

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

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
globset = {
url = "github:pdtpartners/globset";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand Down
31 changes: 15 additions & 16 deletions modules/flake/overlays.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
{ self, inputs, ... }:
{
# Provide overlay to add `nix-snapshotter`.
flake.overlays.default = self: super:
let

in {
nix-snapshotter = self.callPackage ../../package.nix {};
flake.overlays.default = self: super: {
nix-snapshotter = self.callPackage ../../package.nix {
inherit (inputs) globset;
};

k3s = super.k3s_1_30.override {
buildGoModule = args: super.buildGoModule (args // super.lib.optionalAttrs (args.pname != "k3s-cni-plugins" && args.pname != "k3s-containerd") {
vendorHash = {
"sha256-XtTahFaWnuHzKDI/U4d/j4C4gRxH163MCGEEM4hu/WM=" = "sha256-XuMP+ffwTdXKL9q9+ZJUQc5ghGEcdY9UdefjCD19OUE=";
"sha256-Mj9Q3TgqZoJluG4/nyuw2WHnB3OJ+/mlV7duzWt1B1A=" = "sha256-9i0vY+CqrLDKYBZPooccX7OtFhS3//mpKTLntvPYDJo=";
}.${args.vendorHash};
patches = (args.patches or []) ++ [
./patches/k3s-nix-snapshotter.patch
];
});
};
k3s = super.k3s_1_30.override {
buildGoModule = args: super.buildGoModule (args // super.lib.optionalAttrs (args.pname != "k3s-cni-plugins" && args.pname != "k3s-containerd") {
vendorHash = {
"sha256-XtTahFaWnuHzKDI/U4d/j4C4gRxH163MCGEEM4hu/WM=" = "sha256-XuMP+ffwTdXKL9q9+ZJUQc5ghGEcdY9UdefjCD19OUE=";
"sha256-Mj9Q3TgqZoJluG4/nyuw2WHnB3OJ+/mlV7duzWt1B1A=" = "sha256-9i0vY+CqrLDKYBZPooccX7OtFhS3//mpKTLntvPYDJo=";
}.${args.vendorHash};
patches = (args.patches or []) ++ [
./patches/k3s-nix-snapshotter.patch
];
});
};
};

perSystem = { system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
Expand Down
12 changes: 7 additions & 5 deletions package.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, buildGoModule
, closureInfo
, globset
, runCommand
, writeShellScriptBin
, writeText
Expand All @@ -9,13 +10,14 @@
let
nix-snapshotter = buildGoModule {
pname = "nix-snapshotter";
version = "0.2.0";
src = lib.cleanSourceWith {
src = lib.sourceFilesBySuffices ./. [
".go"
version = "0.2.1";
src = lib.fileset.toSource {
root = ./.;
fileset = globset.lib.globs ./. [
"**/*.go"
"**/*.tar"
"go.mod"
"go.sum"
".tar"
];
};
vendorHash = "sha256-QBLePOnfsr6I19ddyZNSFDih6mCaZ/NV2Qz1B1pSHxs=";
Expand Down

0 comments on commit a4dffdc

Please sign in to comment.