improve flake

This commit is contained in:
minish 2024-09-07 19:29:29 -04:00
parent 27a71ae862
commit 62e2598e72
Signed by: min
SSH Key Fingerprint: SHA256:NFjjdbkd6u7aoMlcrDCVvz6o2UBtlAuPm8IQ2vhZ3Fg
4 changed files with 68 additions and 57 deletions

3
.envrc
View File

@ -1 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
fi
use flake use flake

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
# binaries # binaries
/target /target
# nix-direnv
/.direnv

View File

@ -1,17 +1,12 @@
{ {
"nodes": { "nodes": {
"crane": { "crane": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1716080827, "lastModified": 1725409566,
"narHash": "sha256-2R9LBCR8TlMuK4Md9ELwPVuwRQWI3pAh7Nj9e318Hk4=", "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "a7146b04405d93b24a1bac76d93270787872c8be", "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -40,11 +35,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1716097317, "lastModified": 1725534445,
"narHash": "sha256-1UMrLtgzielG/Sop6gl6oTSM4pDt7rF9j9VuxhDWDlY=", "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8535fb92661f37ff9f0da3007fbc942f7d134b41", "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39",
"type": "github" "type": "github"
}, },
"original": { "original": {

102
flake.nix
View File

@ -3,58 +3,68 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane"; crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, crane, flake-utils, ... }: outputs = {
flake-utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
pkgs = nixpkgs.legacyPackages.${system}; crane,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs; craneLib = crane.mkLib pkgs;
# Common arguments can be set here to avoid repeating them later # Common arguments can be set here to avoid repeating them later
# Note: changes here will rebuild all dependency crates # Note: changes here will rebuild all dependency crates
commonArgs = { commonArgs = {
src = craneLib.cleanCargoSource (craneLib.path ./.); src = craneLib.cleanCargoSource ./.;
strictDeps = true; strictDeps = true;
buildInputs = [ buildInputs =
# Add additional build inputs here [
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ]; pkgs.openssl
}; ]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
breeze = craneLib.buildPackage (commonArgs // { # Additional darwin specific inputs can be set here
cargoArtifacts = craneLib.buildDepsOnly commonArgs; pkgs.libiconv
});
in
{
checks = {
inherit breeze;
};
packages.default = breeze;
apps.default = flake-utils.lib.mkApp {
drv = breeze;
};
devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};
# Additional dev-shell environment variables can be set directly
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
# Extra inputs can be added here; cargo and rustc are provided by default.
packages = [
pkgs.rewrk
]; ];
}; };
});
}
breeze = craneLib.buildPackage (commonArgs
// {
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Additional environment variables or build phases/hooks can be set
# here *without* rebuilding all dependency crates
# MY_CUSTOM_VAR = "some value";
});
in {
checks = {
inherit breeze;
};
packages.default = breeze;
apps.default = flake-utils.lib.mkApp {
drv = breeze;
};
devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};
# Additional dev-shell environment variables can be set directly
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
# Extra inputs can be added here; cargo and rustc are provided by default.
packages = [
pkgs.rewrk
];
};
});
}