diff --git a/nix/flake.lock b/nix/flake.lock index 0e8935d..9c03d05 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -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": [ diff --git a/nix/flake.nix b/nix/flake.nix index ab6f4f8..f492a28 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -21,6 +21,11 @@ url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = diff --git a/nix/modules/commonPackages.nix b/nix/modules/commonPackages.nix index 29fa65c..3f8b899 100644 --- a/nix/modules/commonPackages.nix +++ b/nix/modules/commonPackages.nix @@ -50,7 +50,6 @@ gnumake watchman bat - rustup emote pkg-config openssl diff --git a/nix/modules/default.nix b/nix/modules/default.nix index c1704c8..6db9f2f 100644 --- a/nix/modules/default.nix +++ b/nix/modules/default.nix @@ -21,5 +21,6 @@ ./dns.nix ./mounts.nix ./nfs-mesh.nix + ./rust.nix ]; } diff --git a/nix/modules/rust.nix b/nix/modules/rust.nix new file mode 100644 index 0000000..8b01251 --- /dev/null +++ b/nix/modules/rust.nix @@ -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 + ]; + }; +}