cade/flake.nix
2025-11-20 15:31:19 +11:00

59 lines
1.5 KiB
Nix

{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.systems.url = "github:nix-systems/default-linux";
outputs =
{
self,
nixpkgs,
systems,
}:
let
forAllSystems =
function: nixpkgs.lib.genAttrs (import systems) (system: function nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
RUSTFLAGS = "-C prefer-dynamic=yes";
packages = builtins.attrValues {
inherit (pkgs)
rustc
cargo
rust-analyzer
rustfmt
clippy
just
sqlite
;
};
shellHook =
let
justfile = ''
build:
nix build --offline
fresh:
nix build
'';
in
''
echo "${justfile}" > justfile
'';
};
});
packages = forAllSystems (pkgs: {
default =
let
project = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package;
in
pkgs.rustPlatform.buildRustPackage (finalAttrs: {
pname = project.name;
version = project.version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
RUSTFLAGS = "-C prefer-dynamic=yes";
buildInputs = [ pkgs.sqlite ];
});
});
};
}