diff --git a/.gitignore b/.gitignore index d03f68d..0126d97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target /**/target +/result +/result-* diff --git a/flake.lock b/flake.lock index fab92f4..aa56053 100644 --- a/flake.lock +++ b/flake.lock @@ -1,26 +1,5 @@ { "nodes": { - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1654237591, - "narHash": "sha256-+uOzx9fuo3CBHO7aGI+SKxDXpf/7NTOXi0g4UxOdk9k=", - "owner": "nix-community", - "repo": "fenix", - "rev": "8dccfbe51a8adea643ec29a4ec516499a5a081c6", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -39,11 +18,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1653893745, - "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", "owner": "numtide", "repo": "flake-utils", - "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", "type": "github" }, "original": { @@ -52,76 +31,47 @@ "type": "github" } }, - "naersk": { - "inputs": { - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1653413650, - "narHash": "sha256-wojDHjb+eU80MPH+3HQaK0liUy8EgR95rvmCl24i58Y=", - "owner": "nmattia", - "repo": "naersk", - "rev": "69daaceebe12c070cd5ae69ba38f277bbf033695", - "type": "github" - }, - "original": { - "owner": "nmattia", - "repo": "naersk", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1654126564, - "narHash": "sha256-sgDXDKGmUG4h7OPDOHyQggFQ08ZqVzUIPi8351yhugY=", - "owner": "NixOS", + "lastModified": 1660639432, + "narHash": "sha256-2WDiboOCfB0LhvnDVMXOAr8ZLDfm3WdO54CkoDPwN1A=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "f1c9c23aad972787f00f175651e4cb0d7c7fd5ea", + "rev": "6c6409e965a6c883677be7b9d87a95fab6c3472e", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1654126564, - "narHash": "sha256-sgDXDKGmUG4h7OPDOHyQggFQ08ZqVzUIPi8351yhugY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f1c9c23aad972787f00f175651e4cb0d7c7fd5ea", - "type": "github" - }, - "original": { - "id": "nixpkgs", + "owner": "nixos", "ref": "nixpkgs-unstable", - "type": "indirect" + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { - "fenix": "fenix", "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "naersk": "naersk", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" } }, - "rust-analyzer-src": { - "flake": false, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1654178556, - "narHash": "sha256-LG8J9E/wMBolkWS3VstuvhgQ4jOp3Nk328EXlCYY24U=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "88024c7ec2d44a8be8bf05a6580409200cf726fc", + "lastModified": 1660791450, + "narHash": "sha256-I3q06x8HkjavfzvQm2nlGjYwclKfYRYjo3x9jqKBSgA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "98db932adeee26ea311ba4bbbdf4e0e5c3569fc4", "type": "github" }, "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", + "owner": "oxalica", + "repo": "rust-overlay", "type": "github" } } diff --git a/flake.nix b/flake.nix index f4bc1cb..d097383 100644 --- a/flake.nix +++ b/flake.nix @@ -1,76 +1,76 @@ { inputs = { - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "nixpkgs/nixpkgs-unstable"; - naersk.url = "github:nmattia/naersk"; + flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; + rust-overlay.url = "github:oxalica/rust-overlay"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, flake-utils, fenix, nixpkgs, naersk, flake-compat, ... }: - flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (system: - let - pkgs = import nixpkgs { inherit system; }; - toolchain = fenix.packages.${system}.latest; - naersk-lib = (naersk.lib."${system}".override { - inherit (toolchain) cargo rustc; - }); + outputs = { self, nixpkgs, rust-overlay, flake-compat, ... }: + let + pkgsFor = system: import nixpkgs { + inherit system; - mkEww = { wayland ? false }: - naersk-lib.buildPackage { - pname = "eww"; - src = builtins.path { name = "eww"; path = ./.; }; + overlays = [ + self.overlays.default + rust-overlay.overlays.default + ]; + }; - nativeBuildInputs = with pkgs; [ pkg-config gtk3 ]; - buildInputs = pkgs.lib.optional wayland pkgs.gtk-layer-shell; + targetSystems = [ "aarch64-linux" "x86_64-linux" ]; + mkRustToolchain = pkgs: pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + in + { + overlays.default = final: prev: + let + rust = mkRustToolchain final; - cargoBuildOptions = opts: opts ++ pkgs.lib.optionals wayland [ - "--no-default-features" - "--features=wayland" - ]; + rustPlatform = prev.makeRustPlatform { + cargo = rust; + rustc = rust; }; - in - { - apps = rec { - default = eww; - eww = flake-utils.lib.mkApp { drv = self.packages.${system}.eww; }; - eww-wayland = flake-utils.lib.mkApp { drv = self.packages.${system}.eww-wayland; }; + in + { + eww = (prev.eww.override { inherit rustPlatform; }).overrideAttrs (old: { + version = self.rev or "dirty"; + src = builtins.path { name = "eww"; path = prev.lib.cleanSource ./.; }; + cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }; + patches = [ ]; + }); + + eww-wayland = final.eww.override { withWayland = true; }; }; - packages = rec { - default = eww; - eww = mkEww { }; - eww-wayland = mkEww { wayland = true; }; - }; + packages = nixpkgs.lib.genAttrs targetSystems (system: + let + pkgs = pkgsFor system; + in + (self.overlays.default pkgs pkgs) // { + default = self.packages.${system}.eww; + } + ); - devShells.default = pkgs.mkShell { - packages = builtins.attrValues { - inherit (toolchain) - cargo - rustc - rust-src - clippy-preview - rustfmt-preview; - - inherit (pkgs) - rust-analyzer + devShells = nixpkgs.lib.genAttrs targetSystems (system: + let + pkgs = pkgsFor system; + rust = mkRustToolchain pkgs; + in + { + default = pkgs.mkShell { + packages = with pkgs; [ + rust + rust-analyzer-unwrapped gcc gtk3 gtk-layer-shell pkg-config deno - mdbook; - }; + mdbook + ]; - RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library"; - }; - }); + RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library"; + }; + } + ); + }; } diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index d6298cb..00000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2022-04-13 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..8d7a095 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2022-04-13" +components = [ "rust-src" ] +profile = "default"