nix: switch to crane for more efficient building

This commit is contained in:
Greg Shuflin committed 2026-08-16 22:39:07 -07:00
1 parent 6234f5ed52
commit 50f0db2420
2 files changed
+24 -67

No files matched your search

Generated
+9 -54
View File
@@ -1,45 +1,17 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"naersk",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"crane": {
"locked": {
"lastModified": 1752475459,
"narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=",
"owner": "nix-community",
"repo": "fenix",
"rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f",
"lastModified": 1785782307,
"narHash": "sha256-MPaRdVkf6zZP5fCPxYCi8Dr4pZzgmXzg8T9nVEbp3Mw=",
"owner": "ipetkov",
"repo": "crane",
"rev": "2c71e194474d13de031d729b729c968ddbe3507f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"naersk": {
"inputs": {
"fenix": "fenix",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1763384566,
"narHash": "sha256-r+wgI+WvNaSdxQmqaM58lVNvJYJ16zoq+tKN20cLst4=",
"owner": "nix-community",
"repo": "naersk",
"rev": "d4155d6ebb70fbe2314959842f744aa7cabbbf6a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
@@ -61,26 +33,9 @@
},
"root": {
"inputs": {
"naersk": "naersk",
"crane": "crane",
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1752428706,
"narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "591e3b7624be97e4443ea7b5542c191311aa141d",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
}
},
"root": "root",
+15 -13
View File
@@ -2,16 +2,13 @@
description = "Image viewer and renamer";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
};
outputs = {
self,
nixpkgs,
naersk,
crane,
}: let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = cargoToml.package.name;
@@ -28,23 +25,28 @@
system,
}: {
default = let
naersk' = pkgs.callPackage naersk {};
craneLib = crane.mkLib pkgs;
runtimeLibs = with pkgs; [
wayland
libxkbcommon
xorg.libxcb
vulkan-loader
];
commonArgs = {
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = runtimeLibs;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
meganekko = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
});
in
pkgs.symlinkJoin {
name = pname;
paths = [
(naersk'.buildPackage {
src = ./.;
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = runtimeLibs;
})
];
paths = [meganekko];
buildInputs = [pkgs.makeWrapper];
postBuild = ''
wrapProgram $out/bin/${pname} \