-
Notifications
You must be signed in to change notification settings - Fork 286
The Nix pipelines #1573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
The Nix pipelines #1573
Changes from all commits
8c71204
7928e44
0211e90
77afd70
f2b9f7b
b7d3fe6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Doesn't work in the sandbox | ||
[yanked] | ||
enabled = false # Warn for yanked crates in Cargo.lock (default: true) | ||
update_index = false # Auto-update the crates.io index (default: true) |
Sk7Str1p3 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: update-flake-lock | ||
|
||
on: | ||
workflow_dispatch: # allows manual triggering | ||
schedule: | ||
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00 | ||
|
||
jobs: | ||
lockfile: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Install Determinate Nix | ||
uses: DeterminateSystems/nix-installer-action@main | ||
with: | ||
determinate: true | ||
- name: Update flake.lock | ||
uses: DeterminateSystems/update-flake-lock@main | ||
with: | ||
pr-title: "Update flake.lock" # Title of PR to be created | ||
pr-labels: | # Labels to be set on the PR | ||
dependencies | ||
automated |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
/stage | ||
/parts | ||
/prime | ||
.direnv | ||
.gitignore.swp | ||
.DS_Store | ||
result | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[licenses] | ||
allow = ["MIT"] |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to research flake later, but could you discuss the pros of tracking the lock file in the repository? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same pros of tracking cargo.lock in repository - to be sure the shell will be SAME, and to be sure it is going to behave same way anywhere. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
description = "Git repository summary on your terminal"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
|
||
crane.url = "github:ipetkov/crane"; | ||
|
||
flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
advisory-db = { | ||
url = "github:rustsec/advisory-db"; | ||
flake = false; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
|
||
inherit (pkgs) lib; | ||
|
||
craneLib = crane.mkLib pkgs; | ||
src = ./.; | ||
|
||
# Common arguments can be set here to avoid repeating them later | ||
commonArgs = { | ||
inherit src; | ||
strictDeps = true; | ||
|
||
buildInputs = with pkgs; | ||
[ | ||
# package dependencies | ||
zstd | ||
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ | ||
# additional dependencies on Darwin systems | ||
CoreFoundation | ||
libresolv | ||
Security | ||
]); | ||
nativeBuildInputs = with pkgs; [ cmake pkg-config ]; | ||
nativeCheckInputs = with pkgs; [ git ]; | ||
|
||
# Additional environment variables can be set directly | ||
# MY_CUSTOM_VAR = "some value"; | ||
}; | ||
|
||
# Build *just* the cargo dependencies, so we can reuse | ||
# all of that work (e.g. via cachix) when running in CI | ||
cargoArtifacts = craneLib.buildDepsOnly commonArgs; | ||
|
||
# Build the actual crate itself, reusing the dependency | ||
# artifacts from above. | ||
onefetch = | ||
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); | ||
in { | ||
checks = { | ||
# Build the crate as part of `nix flake check` for convenience | ||
inherit onefetch; | ||
|
||
# Run clippy (and deny all warnings) on the crate source, | ||
# again, reusing the dependency artifacts from above. | ||
# | ||
# Note that this is done as a separate derivation so that | ||
# we can block the CI if there are issues here, but not | ||
# prevent downstream consumers from building our crate by itself. | ||
onefetch-clippy = craneLib.cargoClippy (commonArgs // { | ||
inherit cargoArtifacts; | ||
cargoClippyExtraArgs = "--all-targets -- --deny warnings"; | ||
}); | ||
|
||
onefetch-doc = | ||
craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; }); | ||
|
||
# Check formatting | ||
onefetch-fmt = craneLib.cargoFmt { inherit src; }; | ||
|
||
onefetch-toml-fmt = craneLib.taploFmt { | ||
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ]; | ||
# taplo arguments can be further customized below as needed | ||
# taploExtraArgs = "--config ./taplo.toml"; | ||
}; | ||
|
||
# Audit dependencies | ||
onefetch-audit = craneLib.cargoAudit { inherit src advisory-db; }; | ||
|
||
# Audit licenses | ||
onefetch-deny = craneLib.cargoDeny { inherit src; }; | ||
|
||
# Run tests with cargo-nextest | ||
# Consider setting `doCheck = false` on `my-crate` if you do not want | ||
# the tests to run twice | ||
onefetch-nextest = craneLib.cargoNextest (commonArgs // { | ||
inherit cargoArtifacts; | ||
partitions = 1; | ||
partitionType = "count"; | ||
cargoNextestPartitionsExtraArgs = "--no-tests=pass"; | ||
}); | ||
}; | ||
|
||
packages = rec { | ||
onefetch-debug = onefetch // { | ||
cargoExtraArgs = lib.concatStringsSep " " [ | ||
# Just to get more human-readable look | ||
"--profile dev" | ||
]; | ||
}; | ||
inherit onefetch; | ||
default = onefetch-debug; | ||
}; | ||
|
||
apps.default = flake-utils.lib.mkApp { drv = onefetch; }; | ||
|
||
devShells.default = craneLib.devShell { | ||
# Inherit inputs from checks. | ||
checks = self.checks.${system}; | ||
|
||
# Additional dev-shell environment variables can be set directly | ||
# MY_CUSTOM_DEVELOPMENT_VAR = "something else"; | ||
|
||
# Extra inputs can be added here; cargo and rustc are provided by default. | ||
packages = with pkgs; [ | ||
# pkgs.ripgrep | ||
nixd | ||
nixfmt | ||
]; | ||
}; | ||
}); | ||
# Sets substituters to avoid locally building something already built | ||
nixConfig = { | ||
extra-substituters = | ||
[ "https://crane.cachix.org" "https://cache.garnix.io" ]; | ||
extra-trusted-public-keys = [ | ||
"crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk=" | ||
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" | ||
]; | ||
}; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting up TOML formatting sounds good to me, but TBH I think this can go in a separate PR. That way we can get TOML formatting merged in faster while we still discuss flake. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Sorts `Cargo.toml` dependencies. All other `.toml` files are formatted with the default config. | ||
# | ||
# https://taplo.tamasfe.dev/configuration/file.html#configuration-file | ||
|
||
[formatting] | ||
reorder_keys = false | ||
|
||
[[rule]] | ||
include = ["**/Cargo.toml"] | ||
keys = ["dependencies"] | ||
|
||
[rule.formatting] | ||
reorder_keys = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in the sandbox? Does it fail to send HTTP requests to crates.io?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not checked (this is crane generated defaults) but I suppose yes it fails