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

View File

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