refactor(nix): migrate flake.nix to flake-parts
- Replace manual forAllSystems pattern with flake-parts.lib.mkFlake - Use perSystem for packages and devShells definitions - Pin rust-overlay's nixpkgs to follow main nixpkgs input - No functional changes to package or dev shell
This commit is contained in:
parent
c7ea7420ae
commit
583f249059
2 changed files with 80 additions and 74 deletions
40
flake.lock
40
flake.lock
|
|
@ -1,5 +1,23 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1769996383,
|
||||
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1763283776,
|
||||
|
|
@ -16,31 +34,33 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1744536153,
|
||||
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
|
||||
"lastModified": 1769909678,
|
||||
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "72716169fe93074c333e8d0173151350670b824c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1763433504,
|
||||
|
|
|
|||
78
flake.nix
78
flake.nix
|
|
@ -4,6 +4,8 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
};
|
||||
|
||||
outputs =
|
||||
|
|
@ -11,39 +13,40 @@
|
|||
self,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
}:
|
||||
let
|
||||
supportedSystems = [
|
||||
flake-parts,
|
||||
}@inputs:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
|
||||
pkgsForSystem =
|
||||
system:
|
||||
(import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
});
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (
|
||||
system:
|
||||
perSystem =
|
||||
{ config, system, ... }:
|
||||
let
|
||||
inherit (pkgsForSystem system)
|
||||
lib
|
||||
rustPlatform
|
||||
;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
inherit (pkgs) lib rustPlatform;
|
||||
|
||||
rust = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"clippy"
|
||||
"rust-analyzer"
|
||||
"rustfmt"
|
||||
];
|
||||
};
|
||||
|
||||
cargoToml = lib.trivial.importTOML ./Cargo.toml;
|
||||
version = cargoToml.package.version;
|
||||
in
|
||||
rec {
|
||||
default = brewlog;
|
||||
{
|
||||
packages = {
|
||||
default = self.packages.${system}.brewlog;
|
||||
|
||||
brewlog = rustPlatform.buildRustPackage {
|
||||
pname = "brewlog";
|
||||
version = version;
|
||||
inherit version;
|
||||
src = lib.cleanSource ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
|
|
@ -56,23 +59,9 @@
|
|||
maintainers = with lib.maintainers; [ jnsgruk ];
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = pkgsForSystem system;
|
||||
rust = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"clippy"
|
||||
"rust-analyzer"
|
||||
"rustfmt"
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
name = "brewlog";
|
||||
|
||||
|
|
@ -80,19 +69,16 @@
|
|||
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
||||
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
[
|
||||
[ rust ]
|
||||
++ (with pkgs; [
|
||||
cargo-watch
|
||||
nil
|
||||
nixfmt
|
||||
sqlite
|
||||
sqlx-cli
|
||||
]
|
||||
++ [
|
||||
rust
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
]);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue