Skip to content

Commit 3203985

Browse files
committed
devenv
1 parent 38206a9 commit 3203985

File tree

5 files changed

+49
-150
lines changed

5 files changed

+49
-150
lines changed

.dockerignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 24 deletions
This file was deleted.

devenv.nix

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
config,
55
inputs,
66
...
7-
}: {
7+
}:
8+
{
89
# https://devenv.sh/basics/
910
env.GREET = "devenv";
1011

1112
cachix.enable = true;
12-
cachix.pull = ["m00nwtchr"];
13+
cachix.pull = [ "m00nwtchr" ];
1314

1415
# https://devenv.sh/packages/
15-
packages = with pkgs; [git cargo-nextest cargo-audit];
16+
packages = with pkgs; [
17+
git
18+
cargo-nextest
19+
cargo-audit
20+
];
1621

1722
# https://devenv.sh/languages/
1823
languages.rust = {
@@ -23,7 +28,19 @@
2328
};
2429

2530
# https://devenv.sh/services/
26-
# services.postgres.enable = true;
31+
services.postgres = {
32+
enable = true;
33+
initialDatabases = [
34+
{
35+
name = "rssflow";
36+
user = "rssflow";
37+
}
38+
];
39+
};
40+
services.redis = {
41+
enable = true;
42+
package = pkgs.valkey;
43+
};
2744

2845
enterShell = ''
2946
git --version

flake.lock

Lines changed: 15 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
{
22
description = "A devShell example";
3+
nixConfig = {
4+
extra-substituters = [
5+
"https://m00nwtchr.cachix.org"
6+
];
7+
extra-trusted-public-keys = [
8+
"m00nwtchr.cachix.org-1:obUPSTOPq11tzLSzMCHBq/A2PTeIv9qIZW1IxCeb8Yw="
9+
];
10+
};
311
inputs = {
412
crane.url = "github:ipetkov/crane";
513
flake-utils.url = "github:numtide/flake-utils";
6-
fenix.url = "github:nix-community/fenix";
7-
fenix.inputs.nixpkgs.follows = "nixpkgs";
14+
rust-overlay.url = "github:oxalica/rust-overlay";
15+
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
816

917
advisory-db = {
1018
url = "github:rustsec/advisory-db";
@@ -16,33 +24,17 @@
1624
nixpkgs,
1725
crane,
1826
flake-utils,
19-
fenix,
20-
advisory-db,
27+
rust-overlay,
2128
...
2229
}:
2330
flake-utils.lib.eachDefaultSystem (system: let
2431
pkgs = import nixpkgs {
2532
inherit system;
26-
overlays = [fenix.overlays.default];
33+
overlays = [rust-overlay.overlays.default];
2734
};
2835
inherit (pkgs) lib;
2936

30-
rustToolchain = pkgs.fenix.combine (with pkgs.fenix; [
31-
stable.cargo
32-
stable.clippy
33-
stable.rustc
34-
latest.rustfmt
35-
]);
36-
37-
craneLib = (crane.mkLib pkgs).overrideToolchain (p: rustToolchain);
38-
craneDev = craneLib.overrideToolchain (p:
39-
p.fenix.combine (with p.fenix.stable; [
40-
rustToolchain
41-
rust-analyzer
42-
rust-src
43-
]));
44-
45-
craneNightly = craneLib.overrideToolchain pkgs.fenix.minimal.toolchain;
37+
craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.minimal);
4638

4739
root = ./.;
4840
src = lib.fileset.toSource {
@@ -142,56 +134,7 @@
142134
};
143135

144136
dockerImages = lib.mapAttrs mkImage packages;
145-
146-
mkChecks = craneLib: let
147-
cargoArtifacts = mkCargoArtifacts craneLib;
148-
in {
149-
# Run clippy
150-
workspace-clippy = craneLib.cargoClippy (commonArgs
151-
// {
152-
inherit cargoArtifacts;
153-
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
154-
});
155-
156-
# Check formatting
157-
workspace-fmt = craneLib.cargoFmt {
158-
inherit src;
159-
};
160-
161-
# Audit dependencies
162-
workspace-audit = craneLib.cargoAudit {
163-
inherit src advisory-db;
164-
};
165-
166-
# Audit licenses
167-
workspace-deny = craneLib.cargoDeny {
168-
inherit src;
169-
};
170-
171-
# Run tests with cargo-nextest
172-
# Consider setting `doCheck = false` on other crate derivations
173-
# if you do not want the tests to run twice
174-
workspace-nextest = craneLib.cargoNextest (commonArgs
175-
// {
176-
inherit cargoArtifacts;
177-
partitions = 1;
178-
partitionType = "count";
179-
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
180-
});
181-
};
182137
in {
183-
checks =
184-
{
185-
workspace-udeps = craneNightly.mkCargoDerivation (commonArgs
186-
// {
187-
cargoArtifacts = mkCargoArtifacts craneNightly;
188-
pnameSuffix = "-udeps";
189-
buildPhaseCargoCommand = "cargo udeps";
190-
nativeBuildInputs = [pkgs.cargo-udeps];
191-
});
192-
}
193-
// mkChecks craneLib
194-
// packages;
195138
packages =
196139
{
197140
default = packages.rssflow;
@@ -211,17 +154,5 @@
211154
apps.default = flake-utils.lib.mkApp {
212155
drv = packages.rssflow;
213156
};
214-
215-
devShells.default = craneDev.devShell {
216-
checks = (mkChecks craneDev) // mkPackages craneDev;
217-
218-
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.llvmPackages.clangUseLLVM}/bin/clang";
219-
CARGO_ENCODED_RUSTFLAGS = "-Clink-arg=-fuse-ld=${pkgs.mold}/bin/mold";
220-
221-
packages = with pkgs; [
222-
grpcurl
223-
sqlx-cli
224-
];
225-
};
226157
});
227158
}

0 commit comments

Comments
 (0)