From c933e8be01523c62f9cbfff2a7aa336a82f7f6da Mon Sep 17 00:00:00 2001 From: XNM Date: Thu, 9 Nov 2023 22:28:06 +0200 Subject: [PATCH] added `Rust toolchain` nix-way setup --- home/.config/fish/config.fish | 2 +- nixos/configuration.nix | 14 ++--- nixos/flake.lock | 96 +++++++++++++++++++++++++++++++++++ nixos/flake.nix | 9 +++- nixos/rust-toolchain.toml | 9 ++++ 5 files changed, 118 insertions(+), 12 deletions(-) create mode 100644 nixos/flake.lock create mode 100644 nixos/rust-toolchain.toml diff --git a/home/.config/fish/config.fish b/home/.config/fish/config.fish index 8434e38..aff4e21 100644 --- a/home/.config/fish/config.fish +++ b/home/.config/fish/config.fish @@ -6,7 +6,7 @@ alias conf="z ~/.config" alias nixos="z /etc/nixos" alias store="z /nix/store" alias nswitch="sudo nixos-rebuild switch --flake /etc/nixos" -alias nswitchu="sudo nixos-rebuild switch --flake /etc/nixos --upgrade --commit-lock-file" +alias nswitchu="sudo nixos-rebuild switch --flake /etc/nixos --upgrade --update-input nixpkgs --update-input rust-overlay --commit-lock-file" alias ncsu="sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos" alias nsgc="sudo nix-store --gc" alias ncg="sudo nix-collect-garbage -d" diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 8aa4d0d..55698c7 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -155,7 +155,7 @@ enable = true; operation = "switch"; # If you don't want to apply updates immediately, only after rebooting, use `boot` option in this case flake = "/etc/nixos"; - flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ]; + flags = [ "--update-input" "nixpkgs" "--update-input" "rust-overlay" "--commit-lock-file" ]; dates = "daily"; # channel = "https://nixos.org/channels/nixos-unstable"; }; @@ -343,7 +343,7 @@ "gammastep" = { isAllowed = true; isSystem = false; - users = [ "1000" ]; + users = [ "1000" ]; # FIXME: set your user id (to get user id use command 'id -u "your_user_name"') }; }; }; @@ -445,6 +445,7 @@ # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ + gcc13 jdk11 gleam rebar3 @@ -469,9 +470,8 @@ nil zls - rustup evcxr #rust repl - rust-analyzer + taplo #toml formatter & lsp cargo-deny cargo-audit cargo-update @@ -486,11 +486,7 @@ cargo-modules cargo-bloat bacon - taplo #toml formatter & lsp - - lldb - llvmPackages.bintools - gcc13 + lldb_16 wasmedge lunatic diff --git a/nixos/flake.lock b/nixos/flake.lock new file mode 100644 index 0000000..07ed929 --- /dev/null +++ b/nixos/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1699099776, + "narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1699495996, + "narHash": "sha256-m0LWmnEJhHTY4gJX9HPsQ8voZptvr1Sx6dXkk9Xp0sI=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "603e4962d7d2225ba2caf66b0eabfcaa9a93c490", + "type": "github" + }, + "original": { + "owner": "oxalica", + "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", + "version": 7 +} diff --git a/nixos/flake.nix b/nixos/flake.nix index 339035b..9dd1b99 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -3,14 +3,19 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; }; - outputs = { nixpkgs, ... } @ inputs: + outputs = { nixpkgs, rust-overlay, ... } @ inputs: { nixosConfigurations.isitreal-laptop = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; modules = [ - ./configuration.nix + ./configuration.nix + ({ pkgs, ... }: { + nixpkgs.overlays = [ rust-overlay.overlays.default ]; + environment.systemPackages = [ (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml) ]; + }) ]; }; }; diff --git a/nixos/rust-toolchain.toml b/nixos/rust-toolchain.toml new file mode 100644 index 0000000..56722d3 --- /dev/null +++ b/nixos/rust-toolchain.toml @@ -0,0 +1,9 @@ +[toolchain] +channel = "stable" +components = [ "rust-src", "rust-analyzer" ] +targets = [ + "wasm32-wasi", + "x86_64-pc-windows-gnu", + "x86_64-unknown-linux-gnu", + ] +profile = "default"