Compare commits

..

2 Commits

Author SHA1 Message Date
Moritz Böhme 0a0c675552
feat: ignore statix for templates 2024-01-21 14:54:19 +01:00
Moritz Böhme 45a1190af7
feat: improve rust template 2024-01-21 14:53:56 +01:00
2 changed files with 46 additions and 42 deletions

3
statix.toml Normal file
View File

@ -0,0 +1,3 @@
disabled = []
nix_version = '2.4'
ignore = ['.direnv' 'templates']

View File

@ -1,58 +1,59 @@
{ {
inputs = { inputs = {
crane = { crane.url = "github:ipetkov/crane";
url = "github:ipetkov/crane"; crane.inputs.nixpkgs.follows = "nixpkgs";
inputs = { fenix.url = "github:nix-community/fenix";
flake-utils.follows = "flake-utils"; fenix.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.follows = "nixpkgs";
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-unstable";
}; };
outputs = { self, crane, fenix, flake-utils, nixpkgs }: outputs = { self, crane, flake-utils, nixpkgs, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = (import nixpkgs) { inherit (pkgs) lib;
inherit system; pkgs = import nixpkgs { inherit system; };
}; fenix = inputs.fenix.packages.${system};
toolchain = fenix.packages.${system}.stable;
craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain; craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain;
mkSrc = extraPaths: with lib.fileset; let
root = ./.;
rustFiles = fromSource (craneLib.cleanCargoSource root);
fileset = union rustFiles (unions extraPaths);
in
toSource { inherit root fileset; };
## Customize here ##
toolchain = fenix.complete; # or fenix.stable;
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv; stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
in in
{ {
packages = packages.default = craneLib.buildPackage {
let inherit stdenv;
inherit (pkgs.lib) fileset; src = mkSrc [ ];
without = fs: fileset.difference ./. fs; strictDeps = true;
nixFiles = fileset.unions [ ./flake.nix ./flake.lock ./.envrc ]; buildInputs = [
gitFiles = fileset.gitTracked ./.; # Add additional build inputs here
src = fileset.toSource { ] ++ lib.optionals pkgs.stdenv.isDarwin [
root = ./.; # Additional darwin specific inputs can be set here
fileset = fileset.intersection (without nixFiles) gitFiles; pkgs.libiconv
}; ];
in # Additional environment variables can be set directly
{ # MY_CUSTOM_VAR = "some value";
default =
craneLib.buildPackage {
inherit src stdenv;
};
}; };
devShell = pkgs.mkShell.override devShells.default = pkgs.mkShell.override { inherit stdenv; }
{ {
inherit stdenv; nativeBuildInputs = with pkgs; [
} # Add additional build inputs here
{ ] ++ (with toolchain; [
nativeBuildInputs = with toolchain; cargo
[ rustc cargo rust-analyzer clippy ] ++ (with pkgs; clippy
[ ] rustfmt
); rustc
fenix.rust-analyzer
]);
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
}; };
}); }
);
} }