From 3e98dcb93e52c125b0903d58324d9e68a487c0c9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 31 Oct 2024 23:20:10 +0300 Subject: [PATCH 1/3] nix: re-organize flake structure --- flake.nix | 22 +++++++++---------- .../home-manager.nix} | 8 +++---- nix/{default.nix => packages/anyrun.nix} | 2 +- .../default.nix => packages/plugin.nix} | 0 4 files changed, 15 insertions(+), 17 deletions(-) rename nix/{hm-module.nix => modules/home-manager.nix} (99%) rename nix/{default.nix => packages/anyrun.nix} (96%) rename nix/{plugins/default.nix => packages/plugin.nix} (100%) diff --git a/flake.nix b/flake.nix index 82e52be..f22be33 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ # it is possible to streamline calling packages with a single function # that takes name as an argument, and handles default inherits. mkPlugin = name: - callPackage ./nix/plugins/default.nix { + callPackage ./nix/packages/plugin.nix { inherit inputs lockFile; inherit name; }; @@ -44,8 +44,8 @@ # By default the anyrun package is built without any plugins # as per the `dontBuildPlugins` arg. - anyrun = callPackage ./nix/default.nix {inherit inputs lockFile;}; - anyrun-with-all-plugins = callPackage ./nix/default.nix { + anyrun = callPackage ./nix/packages/anyrun.nix {inherit inputs lockFile;}; + anyrun-with-all-plugins = callPackage ./nix/packages/anyrun.nix { inherit inputs lockFile; dontBuildPlugins = false; }; @@ -72,19 +72,19 @@ default = pkgs.mkShell { inputsFrom = builtins.attrValues self'.packages; packages = with pkgs; [ - rustc # rust compiler + rustc gcc - cargo # rust package manager - clippy # opinionated rust formatter + cargo + clippy + rustfmt ]; }; nix = pkgs.mkShellNoCC { packages = with pkgs; [ - alejandra # nix formatter - rustfmt # rust formatter - statix # lints and suggestions - deadnix # clean up unused nix code + alejandra # formatter + statix # linter + deadnix # dead-code finder ]; }; }; @@ -95,7 +95,7 @@ flake = { homeManagerModules = { - anyrun = import ./nix/hm-module.nix self; + anyrun = import ./nix/modules/home-manager.nix self; default = self.homeManagerModules.anyrun; }; }; diff --git a/nix/hm-module.nix b/nix/modules/home-manager.nix similarity index 99% rename from nix/hm-module.nix rename to nix/modules/home-manager.nix index 5a92f81..a38a6e0 100644 --- a/nix/hm-module.nix +++ b/nix/modules/home-manager.nix @@ -2,13 +2,8 @@ self: { config, pkgs, lib, - hm, ... }: let - cfg = config.programs.anyrun; - - defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default; - inherit (builtins) map toJSON toString substring stringLength; inherit (lib.modules) mkIf mkMerge; inherit (lib.options) mkOption mkEnableOption literalExpression; @@ -17,6 +12,9 @@ self: { inherit (lib.strings) toLower toUpper replaceStrings; inherit (lib.trivial) boolToString; inherit (lib.types) nullOr package submodule int float listOf either str enum lines bool attrs; + + defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default; + cfg = config.programs.anyrun; in { meta.maintainers = with lib.maintainers; [n3oney NotAShelf]; diff --git a/nix/default.nix b/nix/packages/anyrun.nix similarity index 96% rename from nix/default.nix rename to nix/packages/anyrun.nix index b7e4849..6244286 100644 --- a/nix/default.nix +++ b/nix/packages/anyrun.nix @@ -22,7 +22,7 @@ }: let inherit (builtins) fromTOML readFile; - cargoToml = fromTOML (readFile ../anyrun/Cargo.toml); + cargoToml = fromTOML (readFile ../../anyrun/Cargo.toml); pname = cargoToml.package.name; version = cargoToml.package.version; in diff --git a/nix/plugins/default.nix b/nix/packages/plugin.nix similarity index 100% rename from nix/plugins/default.nix rename to nix/packages/plugin.nix From 591d08e430cac6a92e956388302a3e54a78526de Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 31 Oct 2024 23:25:08 +0300 Subject: [PATCH 2/3] chore: shut up resolver warning --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index a197e03..65eec8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "anyrun", "anyrun-plugin", From 57139e050b7d206c8ab857196062726e1c7f15d9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 31 Oct 2024 23:25:35 +0300 Subject: [PATCH 3/3] nix/packages: fix incramental builds variable https://doc.rust-lang.org/cargo/reference/config.html --- nix/packages/anyrun.nix | 8 ++++---- nix/packages/plugin.nix | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/nix/packages/anyrun.nix b/nix/packages/anyrun.nix index 6244286..8d49958 100644 --- a/nix/packages/anyrun.nix +++ b/nix/packages/anyrun.nix @@ -39,8 +39,6 @@ in inherit lockFile; }; - checkInputs = [cargo rustc]; - nativeBuildInputs = [ pkg-config makeWrapper @@ -63,6 +61,8 @@ in else []; doCheck = true; + checkInputs = [cargo rustc]; + copyLibs = true; buildAndTestSubdir = @@ -70,7 +70,7 @@ in then pname else null; - CARGO_BUILD_INCREMENTAL = "false"; + CARGO_BUILD_INCREMENTAL = 0; RUST_BACKTRACE = "full"; postInstall = '' @@ -82,7 +82,7 @@ in meta = { description = "A wayland native, highly customizable runner."; homepage = "https://github.com/Kirottu/anyrun"; - license = with lib.licenses; [gpl3]; + license = [lib.licenses.gpl3]; mainProgram = "anyrun"; maintainers = with lib.maintainers; [NotAShelf n3oney]; }; diff --git a/nix/packages/plugin.nix b/nix/packages/plugin.nix index 06143df..1033a6a 100644 --- a/nix/packages/plugin.nix +++ b/nix/packages/plugin.nix @@ -10,6 +10,8 @@ gtk-layer-shell, pkg-config, librsvg, + cargo, + rustc, # Generic args name, lockFile, @@ -49,17 +51,22 @@ in ++ extraInputs; doCheck = true; + checkInputs = [ + cargo + rustc + ]; + copyLibs = true; cargoBuildFlags = ["-p ${name}"]; buildAndTestSubdir = "plugins/${name}"; - CARGO_BUILD_INCREMENTAL = "false"; + CARGO_BUILD_INCREMENTAL = 0; RUST_BACKTRACE = "full"; meta = { description = "The ${name} plugin for Anyrun"; homepage = "https://github.com/Kirottu/anyrun"; - license = with lib.licenses; [gpl3]; + license = [lib.licenses.gpl3]; maintainers = with lib.maintainers; [NotAShelf n3oney]; }; }