Skip to content

Commit

Permalink
chore: Update nix flake inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian May committed Sep 2, 2024
1 parent 7be35c0 commit 7e49901
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 123 deletions.
29 changes: 12 additions & 17 deletions flake.lock

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

208 changes: 102 additions & 106 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,120 +6,116 @@
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
};

outputs = inputs:
with inputs;
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
pkgs_unstable = import nixpkgs-unstable {
inherit system;
# Required for helm-secrets:
# This will not be required anymore after 24.11 is released,
# See https://github.com/NixOS/nixpkgs/issues/309976
config.allowUnfree = true;
};

osxlibs = pkgs.lib.lists.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.Foundation
outputs = {
nixpkgs,
nixpkgs-unstable,
flake-utils,
rust-overlay,
crane,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
pkgs_unstable = nixpkgs-unstable.legacyPackages.${system};

osxlibs = pkgs.lib.lists.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.Foundation
];

src = ./.;

rustPlatform = pkgs.rust-bin.stable.latest.default;

craneLib = (crane.mkLib pkgs).overrideToolchain rustPlatform;

# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly {inherit src;};

# Run clippy (and deny all warnings) on the crate source.
clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
cargoClippyExtraArgs = "-- --deny warnings";
};

# Next, we want to run the tests and collect code-coverage, _but only if
# the clippy checks pass_ so we do not waste any extra cycles.
coverage = craneLib.cargoTarpaulin {
inherit src;
cargoArtifacts = clippy;
};

# create the workspace & dependencies package set
pkg = craneLib.buildPackage {
inherit src;
inherit cargoArtifacts;
buildInputs = osxlibs;

# Add extra inputs here or any other derivation settings
doCheck = true;
};

awscli = pkgs.awscli2;
vals = pkgs.vals;
gnupg = pkgs.gnupg;

sops = pkgs.writeShellScriptBin "sops" ''
export SOPS_GPG_EXEC=${gnupg}/bin/gpg
exec ${pkgs.sops}/bin/sops "$@"
'';

helm = pkgs.wrapHelm pkgs.kubernetes-helm {
plugins = [
pkgs.kubernetes-helmPlugins.helm-diff
pkgs_unstable.kubernetes-helmPlugins.helm-secrets
];

src = ./.;

rustPlatform = pkgs.rust-bin.stable.latest.default;

craneLib = (crane.mkLib pkgs).overrideToolchain rustPlatform;

# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly { inherit src; };

# Run clippy (and deny all warnings) on the crate source.
clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
cargoClippyExtraArgs = "-- --deny warnings";
};

# Next, we want to run the tests and collect code-coverage, _but only if
# the clippy checks pass_ so we do not waste any extra cycles.
coverage = craneLib.cargoTarpaulin {
inherit src;
cargoArtifacts = clippy;
};

# create the workspace & dependencies package set
pkg = craneLib.buildPackage {
inherit src;
inherit cargoArtifacts;
buildInputs = osxlibs;

# Add extra inputs here or any other derivation settings
doCheck = true;
};

awscli = pkgs.awscli2;
vals = pkgs.vals;
gnupg = pkgs.gnupg;

sops = pkgs.writeShellScriptBin "sops" ''
export SOPS_GPG_EXEC=${gnupg}/bin/gpg
exec ${pkgs.sops}/bin/sops "$@"
'';

helm = pkgs.wrapHelm pkgs.kubernetes-helm {
plugins = [
pkgs.kubernetes-helmPlugins.helm-diff
pkgs_unstable.kubernetes-helmPlugins.helm-secrets
];
extraMakeWrapperArgs =
"--set HELM_SECRETS_SOPS_PATH ${sops}/bin/sops --set HELM_SECRETS_VALS_PATH ${vals}/bin/vals";
};

helmci = pkgs.writeShellScriptBin "helmci" ''
export HELM_PATH=${helm}/bin/helm
export AWS_PATH=${awscli}/bin/aws
exec ${pkg}/bin/helmci "$@"
'';

# The workspace defines a development shell with all of the dependencies
# and environment settings necessary for a regular `cargo build`
rustSrcPlatform =
rustPlatform.override { extensions = [ "rust-src" ]; };
workspaceShell = pkgs.mkShell {
buildInputs = [
extraMakeWrapperArgs = "--set HELM_SECRETS_SOPS_PATH ${sops}/bin/sops --set HELM_SECRETS_VALS_PATH ${vals}/bin/vals";
};

helmci = pkgs.writeShellScriptBin "helmci" ''
export HELM_PATH=${helm}/bin/helm
export AWS_PATH=${awscli}/bin/aws
exec ${pkg}/bin/helmci "$@"
'';

# The workspace defines a development shell with all of the dependencies
# and environment settings necessary for a regular `cargo build`
rustSrcPlatform =
rustPlatform.override {extensions = ["rust-src"];};
workspaceShell = pkgs.mkShell {
buildInputs =
[
pkgs_unstable.rust-analyzer
rustSrcPlatform
helm
awscli
sops
vals
gnupg
] ++ osxlibs;
};

in rec {
checks = { inherit clippy coverage pkg; };
packages = {
inherit helmci helm awscli sops vals gnupg;
default = pkgs.runCommand "helmci-all" { } ''
mkdir -p $out/bin
ln -s ${helmci}/bin/helmci $out/bin/helmci
ln -s ${helm}/bin/helm $out/bin/helm
ln -s ${awscli}/bin/aws $out/bin/aws
ln -s ${sops}/bin/sops $out/bin/sops
ln -s ${vals}/bin/vals $out/bin/vals
ln -s ${gnupg}/bin/gpg $out/bin/gpg
'';
};
devShells.default = workspaceShell;
});
]
++ osxlibs;
};
in {
checks = {inherit clippy coverage pkg;};
packages = {
inherit helmci helm awscli sops vals gnupg;
default = pkgs.runCommand "helmci-all" {} ''
mkdir -p $out/bin
ln -s ${helmci}/bin/helmci $out/bin/helmci
ln -s ${helm}/bin/helm $out/bin/helm
ln -s ${awscli}/bin/aws $out/bin/aws
ln -s ${sops}/bin/sops $out/bin/sops
ln -s ${vals}/bin/vals $out/bin/vals
ln -s ${gnupg}/bin/gpg $out/bin/gpg
'';
};
devShells.default = workspaceShell;
});
}

0 comments on commit 7e49901

Please sign in to comment.