{ description = "My own sheet-organizer using rust and relm4 (and nix)"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; }; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, crane, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; craneLib = crane.mkLib pkgs; dbMigrationsFilter = path: _type: builtins.match ".*sql$" path != null; dbMigrationsOrCargoFilter = path: type: (dbMigrationsFilter path type) || (craneLib.filterCargoSources path type); dbMigrations = pkgs.lib.cleanSourceWith { src = craneLib.path ./db-migrations; # The original, unfiltered source filter = dbMigrationsFilter; }; # Common arguments can be set here to avoid repeating them later # Note: changes here will rebuild all dependency crates commonArgs = rec { src = pkgs.lib.cleanSourceWith { src = craneLib.path ./.; # The original, unfiltered source filter = dbMigrationsOrCargoFilter; }; # src = craneLib.cleanCargoSource (craneLib.path ./.); # Add icons.toml to $src when compiling dependencies (needed by relm4-icons) # Add db-migrations to $src when compiling dependencies (needed by sqlx) extraDummyScript = '' cp --no-preserve=mode,ownership ${./icons.toml} $out/icons.toml mkdir -p $out/db-migrations cp -r --no-preserve=mode,ownership ${dbMigrations} --no-target-dir $out/db-migrations/ ''; nativeBuildInputs = with pkgs; [ pkg-config gtk4 ]; buildInputs = [ # Add additional build inputs here ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ # Additional darwin specific inputs can be set here pkgs.libiconv ]; }; my-crate = craneLib.buildPackage (commonArgs // { cargoArtifacts = craneLib.buildDepsOnly commonArgs; # Additional environment variables or build phases/hooks can be set # here *without* rebuilding all dependency crates # MY_CUSTOM_VAR = "some value"; }); in { checks = { inherit my-crate; }; packages.default = my-crate; apps.default = flake-utils.lib.mkApp { drv = my-crate; }; 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; [ # rustPackages.clippy # rustfmt # pre-commit ]; }; }); }