diff --git a/flake.lock b/flake.lock index 253ea4d..7cb8952 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "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" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -126,9 +144,31 @@ "hyprland-hy3": "hyprland-hy3", "hyprpaper": "hyprpaper", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "stable": "stable" } }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1687400833, + "narHash": "sha256-rVENiSupjAE8o1+ZXNRIqewUzM2brm+aeme8MUrwl0U=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "fc0a266e836c079a9131108f4334e5af219dbb93", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "stable": { "locked": { "lastModified": 1687093939, @@ -144,6 +184,21 @@ "type": "indirect" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "wlroots": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 7a2b3d3..961bf42 100755 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,12 @@ url = "github:hyprwm/Hyprpaper"; inputs.nixpkgs.follows = "nixpkgs"; }; + + # devenv + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs @ { self, nixpkgs, ... }: { @@ -33,6 +39,7 @@ modules = [ (import ./modules/impurity.nix self) ./modules/preserve-system.nix + ./modules/devenv ./modules/overlay-pkgs ./modules/core ./modules/system.nix diff --git a/modules/devenv/default.nix b/modules/devenv/default.nix new file mode 100644 index 0000000..f2668d4 --- /dev/null +++ b/modules/devenv/default.nix @@ -0,0 +1,11 @@ +outerInputs @ { inputs, system, pkgs, ... }: { + nix.registry.devenv.flake.outPath = pkgs.runCommand "devenvs" {} '' + mkdir $out + cp -r ${./.}/* $out + cp ${inputs.self}/flake.lock $out/flake.lock + ''; + + system.extraDependencies = [ + (import ./rust.nix outerInputs) + ]; +} diff --git a/modules/devenv/flake.nix b/modules/devenv/flake.nix new file mode 100644 index 0000000..130e909 --- /dev/null +++ b/modules/devenv/flake.nix @@ -0,0 +1,44 @@ +{ + # locked by the copied lockfile. inputs must match the main flake + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + stable.url = "nixpkgs/nixos-23.05"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + hyprland = { + url = "github:hyprwm/Hyprland"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + hyprland-hy3 = { + url = "github:outfoxxed/hy3"; + inputs.hyprland.follows = "hyprland"; + }; + + hyprpaper = { + url = "github:hyprwm/Hyprpaper"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # devenv + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = finputs @ { nixpkgs, ... }: let + systems = [ "x86_64-linux" ]; + in builtins.foldl' (a: b: a // b) {} (builtins.map (system: let + pkgs = import nixpkgs { inherit system; }; + inputs = finputs // { inherit system pkgs inputs; }; + in { + devShells.${system} = { + rust = import ./rust.nix inputs; + }; + }) systems); +} diff --git a/modules/devenv/rust.nix b/modules/devenv/rust.nix new file mode 100644 index 0000000..e63a56a --- /dev/null +++ b/modules/devenv/rust.nix @@ -0,0 +1,28 @@ +outerInputs @ { inputs, ... }: let + pkgs = outerInputs.pkgs.appendOverlays [ (import inputs.rust-overlay) ]; +in pkgs.mkShell { + name = "rust-devenv"; + packages = with pkgs; [ + (rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + extensions = [ + "rustc" + "rust-src" + "rust-docs" + "rust-std" + "cargo" + "clippy" + "rust-analyzer" + "miri" + ]; + })) + + cargo-expand + + # common deps + clang + pkg-config + openssl.dev + ]; + + shellHook = "exec $SHELL"; +}