build: use flake-parts

This commit is contained in:
2026-03-31 01:06:03 +02:00
parent 0ca3ec6973
commit 0bdeb2ceab
2 changed files with 59 additions and 59 deletions

50
flake.lock generated
View File

@@ -108,21 +108,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-parts_2": {
"inputs": { "inputs": {
"systems": "systems" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1731533236, "lastModified": 1772408722,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=",
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"type": "github" "type": "github"
} }
}, },
@@ -231,6 +231,21 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"lastModified": 1772328832,
"narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1774386573, "lastModified": 1774386573,
@@ -276,7 +291,7 @@
"root": { "root": {
"inputs": { "inputs": {
"crate2nix": "crate2nix", "crate2nix": "crate2nix",
"flake-utils": "flake-utils", "flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
@@ -300,21 +315,6 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"systems": {
"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

@@ -3,38 +3,34 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-utils.url = "github:numtide/flake-utils";
crate2nix = { crate2nix = {
url = "github:nix-community/crate2nix"; url = "github:nix-community/crate2nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
nixConfig = { outputs = inputs @ {
extra-trusted-public-keys = "eigenvalue.cachix.org-1:ykerQDDa55PGxU25CETy9wF6uVDpadGGXYrFNJA3TUs="; flake-parts,
extra-substituters = "https://eigenvalue.cachix.org";
allow-import-from-derivation = true;
};
outputs = {
crate2nix,
flake-utils,
nixpkgs,
rust-overlay, rust-overlay,
crate2nix,
... ...
}: }:
flake-utils.lib.eachDefaultSystem ( flake-parts.lib.mkFlake {inherit inputs;} (top: {
system: let systems = [
# Overlay pkgs with rust-bin "x86_64-linux"
overlays = [(import rust-overlay)]; ];
pkgs = import nixpkgs {
inherit system overlays;
};
perSystem = {
self',
pkgs,
system,
...
}: let
# Use rust-bin to generate the toolchain from rust-toolchain.toml # Use rust-bin to generate the toolchain from rust-toolchain.toml
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
@@ -77,37 +73,41 @@
cargoNix = import generatedCargoNix { cargoNix = import generatedCargoNix {
inherit pkgs buildRustCrateForPkgs; inherit pkgs buildRustCrateForPkgs;
}; };
in rec { in {
apps = rec { _module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
packages.lispers = cargoNix.workspaceMembers.lispers.build;
packages.default = self'.packages.lispers;
apps = {
lisp_demo = { lisp_demo = {
type = "app"; type = "app";
program = "${packages.default}/bin/lisp_demo"; program = "${self'.packages.lispers}/bin/lisp_demo";
}; };
repl = { repl = {
type = "app"; type = "app";
program = "${packages.default}/bin/repl"; program = "${self'.packages.lispers}/bin/repl";
}; };
rt_demo = { rt_demo = {
type = "app"; type = "app";
program = "${packages.default}/bin/rt_demo"; program = "${self'.packages.lispers}/bin/rt_demo";
}; };
rt_demo_lisp = { rt_demo_lisp = {
type = "app"; type = "app";
program = "${packages.default}/bin/rt_lisp_demo"; program = "${self'.packages.lispers}/bin/rt_lisp_demo";
}; };
rt_interp = { rt_interp = {
type = "app"; type = "app";
program = "${packages.default}/bin/rt_interp"; program = "${self'.packages.lispers}/bin/rt_interp";
}; };
default = rt_demo_lisp; default = self'.apps.rt_demo_lisp;
}; };
packages = rec {
lispers = cargoNix.workspaceMembers.lispers.build; devShells.default = pkgs.mkShell {
default = lispers; buildInputs = [rust-toolchain];
}; };
devShell = pkgs.mkShell {
buildInputs = [rust-toolchain pkgs.cargo-edit pkgs.pkg-config pkgs.ffmpeg.dev pkgs.ffmpeg];
}; };
} });
);
} }