feat: use fenix for cargo, add dynamic linking and pkg-config paths

This commit is contained in:
2026-01-17 12:52:13 -08:00
parent ee0cb47e34
commit 68588f5d72
5 changed files with 86 additions and 1 deletions

39
nix/flake.lock generated
View File

@@ -81,6 +81,27 @@
},
"parent": []
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1768632427,
"narHash": "sha256-Y6kP10exkn5UiK9ead2Gky8TFsFZSsyT4f69DMKm0Wo=",
"owner": "nix-community",
"repo": "fenix",
"rev": "edd560269f0d9ad75bd3da292ce4d9d27efdd22a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@@ -189,6 +210,7 @@
"root": {
"inputs": {
"custom-fonts": "custom-fonts",
"fenix": "fenix",
"home-manager": "home-manager",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2",
@@ -197,6 +219,23 @@
"status-bar": "status-bar"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1768468158,
"narHash": "sha256-DfifO/Se9ogmp5rxe/OwmRIz20/w6BsbWC1s4kL1Bzc=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "adbff8baedae53f9955fe60c0d470ecd77b4f548",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [

View File

@@ -21,6 +21,11 @@
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =

View File

@@ -50,7 +50,6 @@
gnumake
watchman
bat
rustup
emote
pkg-config
openssl

View File

@@ -21,5 +21,6 @@
./dns.nix
./mounts.nix
./nfs-mesh.nix
./rust.nix
];
}

41
nix/modules/rust.nix Normal file
View File

@@ -0,0 +1,41 @@
{
pkgs,
lib,
config,
inputs,
...
}:
{
options.rust = {
enable = lib.mkEnableOption "enable rust" // {
default = true;
};
};
config = lib.mkIf config.rust.enable {
nixpkgs.overlays = [ inputs.fenix.overlays.default ];
environment.systemPackages = with pkgs; [
(pkgs.fenix.stable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
openssl
pkgconf
];
environment.variables = {
PKG_CONFIG_PATH =
with pkgs;
lib.makeSearchPath "/lib/pkgconfig" [
openssl.dev
];
LD_LIBRARY_PATH = "/run/current-system/sw/share/nix-ld/lib";
};
programs.nix-ld.libraries = with pkgs; [
openssl
zlib
];
};
}