ref(nix): switch to flake-parts

This commit is contained in:
b4mbus
2024-06-09 00:43:05 +02:00
parent f6304e946a
commit 6233397dfe
2 changed files with 97 additions and 73 deletions

75
flake.lock generated
View File

@@ -1,5 +1,23 @@
{ {
"nodes": { "nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1717285511,
"narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@@ -18,38 +36,32 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": { "nixpkgs": {
"inputs": {
"systems": "systems_2"
},
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1717602782,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=",
"owner": "numtide", "owner": "NixOS",
"repo": "flake-utils", "repo": "nixpkgs",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "NixOS",
"repo": "flake-utils", "ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1707877513, "lastModified": 1717284937,
"narHash": "sha256-sp0w2apswd3wv0sAEF7StOGHkns3XUQaO5erhWFZWXk=", "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=",
"owner": "nixos", "type": "tarball",
"repo": "nixpkgs", "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
"rev": "89653a03e0915e4a872788d10680e7eec92f8600",
"type": "github"
}, },
"original": { "original": {
"owner": "nixos", "type": "tarball",
"ref": "nixpkgs-unstable", "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
"repo": "nixpkgs",
"type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
@@ -70,14 +82,14 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
@@ -108,21 +120,6 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@@ -2,53 +2,80 @@
description = "Terminal session recorder"; description = "Terminal session recorder";
inputs = { inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable; nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
rust-overlay.url = github:oxalica/rust-overlay; rust-overlay.url = github:oxalica/rust-overlay;
flake-utils.url = github:numtide/flake-utils; flake-parts.url = github:hercules-ci/flake-parts;
}; };
outputs = { self, nixpkgs, rust-overlay, flake-utils }: outputs = inputs @ {
flake-utils.lib.eachDefaultSystem (system: flake-parts,
let rust-overlay,
overlays = [ (import rust-overlay) ]; ...
pkgs = import nixpkgs { inherit system overlays; }; }:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
msrv = cargoToml.package.rust-version; msrv = cargoToml.package.rust-version;
buildDeps = rust: with pkgs; [ buildDeps = rust:
rust with pkgs;
] ++ (lib.optionals stdenv.isDarwin [ [
libiconv rust
darwin.apple_sdk.frameworks.Foundation ]
]) ++ testDeps; ++ (lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Foundation
])
++ testDeps;
testDeps = with pkgs; [ testDeps = with pkgs; [
python3 python3
]; ];
mkDevShell = rust: pkgs.mkShell { mkDevShell = rust:
nativeBuildInputs = buildDeps (rust.override { pkgs.mkShell {
extensions = [ "rust-src" ]; nativeBuildInputs = buildDeps (rust.override {
}); extensions = ["rust-src"];
});
RUST_BACKTRACE = 1; RUST_BACKTRACE = 1;
}; };
mkPackage = rust: (pkgs.makeRustPlatform { mkPackage = rust:
cargo = rust; (pkgs.makeRustPlatform {
rustc = rust; cargo = rust;
}).buildRustPackage { rustc = rust;
inherit (cargoToml.package) name version; })
src = ./.; .buildRustPackage {
cargoLock.lockFile = ./Cargo.lock; inherit (cargoToml.package) name version;
nativeBuildInputs = buildDeps rust; src = ./.;
dontUseCargoParallelTests = true; cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = buildDeps rust;
dontUseCargoParallelTests = true;
};
in {
_module.args = {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
};
formatter = pkgs.alejandra;
devShells = {
default = mkDevShell pkgs.rust-bin.stable.latest.default;
msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default;
}; };
in
{
devShells.default = mkDevShell pkgs.rust-bin.stable.latest.default;
devShells.msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default;
packages.default = mkPackage pkgs.rust-bin.stable.latest.minimal; packages.default = mkPackage pkgs.rust-bin.stable.latest.minimal;
} };
); };
} }