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": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1763283776,
|
"lastModified": 1763283776,
|
||||||
|
|
@ -16,31 +34,33 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1744536153,
|
"lastModified": 1769909678,
|
||||||
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
|
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
|
||||||
"owner": "NixOS",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
|
"rev": "72716169fe93074c333e8d0173151350670b824c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "nix-community",
|
||||||
"ref": "nixpkgs-unstable",
|
"repo": "nixpkgs.lib",
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1763433504,
|
"lastModified": 1763433504,
|
||||||
|
|
|
||||||
76
flake.nix
76
flake.nix
|
|
@ -4,6 +4,8 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
|
|
@ -11,39 +13,40 @@
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
rust-overlay,
|
rust-overlay,
|
||||||
}:
|
flake-parts,
|
||||||
let
|
}@inputs:
|
||||||
supportedSystems = [
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
];
|
];
|
||||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
||||||
|
|
||||||
pkgsForSystem =
|
perSystem =
|
||||||
system:
|
{ config, system, ... }:
|
||||||
(import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
overlays = [ (import rust-overlay) ];
|
|
||||||
});
|
|
||||||
in
|
|
||||||
{
|
|
||||||
packages = forAllSystems (
|
|
||||||
system:
|
|
||||||
let
|
let
|
||||||
inherit (pkgsForSystem system)
|
overlays = [ (import rust-overlay) ];
|
||||||
lib
|
pkgs = import nixpkgs { inherit system overlays; };
|
||||||
rustPlatform
|
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;
|
cargoToml = lib.trivial.importTOML ./Cargo.toml;
|
||||||
version = cargoToml.package.version;
|
version = cargoToml.package.version;
|
||||||
in
|
in
|
||||||
rec {
|
{
|
||||||
default = brewlog;
|
packages = {
|
||||||
|
default = self.packages.${system}.brewlog;
|
||||||
|
|
||||||
brewlog = rustPlatform.buildRustPackage {
|
brewlog = rustPlatform.buildRustPackage {
|
||||||
pname = "brewlog";
|
pname = "brewlog";
|
||||||
version = version;
|
inherit version;
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
|
||||||
|
|
@ -56,23 +59,9 @@
|
||||||
maintainers = with lib.maintainers; [ jnsgruk ];
|
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 {
|
default = pkgs.mkShell {
|
||||||
name = "brewlog";
|
name = "brewlog";
|
||||||
|
|
||||||
|
|
@ -80,19 +69,16 @@
|
||||||
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
with pkgs;
|
[ rust ]
|
||||||
[
|
++ (with pkgs; [
|
||||||
cargo-watch
|
cargo-watch
|
||||||
nil
|
nil
|
||||||
nixfmt
|
nixfmt
|
||||||
sqlite
|
sqlite
|
||||||
sqlx-cli
|
sqlx-cli
|
||||||
]
|
]);
|
||||||
++ [
|
};
|
||||||
rust
|
};
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue