From cb6fdbcbaa561ca5c1768a9019138d22d7d9b4ad Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 3 Jun 2024 19:45:35 +0300 Subject: [PATCH 1/5] nix: streamline plugin package generation Simplifies nix code and gets rid of discouraged rec pattern in flake.nix --- flake.nix | 90 ++++++++++++++++++------------------------------------- 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/flake.nix b/flake.nix index e7da398..0bdf39a 100644 --- a/flake.nix +++ b/flake.nix @@ -22,8 +22,7 @@ system, ... }: let - inherit (inputs.nixpkgs) lib; - inherit (lib) getExe; + inherit (pkgs) callPackage; in { # provide the formatter for nix fmt formatter = pkgs.alejandra; @@ -45,78 +44,47 @@ packages = let lockFile = ./Cargo.lock; - in rec { - anyrun = pkgs.callPackage ./nix/default.nix {inherit inputs lockFile;}; - # alias nix build .# to anyrun - default = anyrun; + + # Since all plugin derivations are called with the exact same arguments + # 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 { + inherit inputs lockFile; + inherit name; + }; + in { + default = self'.packages.anyrun; + anyrun = callPackage ./nix/default.nix {inherit inputs lockFile;}; anyrun-with-all-plugins = pkgs.callPackage ./nix/default.nix { inherit inputs lockFile; dontBuildPlugins = false; }; - # expose each plugin as a package - applications = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "applications"; - }; - - dictionary = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "dictionary"; - }; - - kidex = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "kidex"; - }; - - randr = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "randr"; - }; - - rink = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "rink"; - }; - - shell = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "shell"; - }; - - stdin = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "stdin"; - }; - - symbols = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "symbols"; - }; - - translate = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "translate"; - }; - - websearch = pkgs.callPackage ./nix/plugins/default.nix { - inherit inputs lockFile; - name = "websearch"; - }; + # Expose each plugin as a separate package. This uses the mkPlugin function + # to call the same derivation with same default inherits and the name of the + # plugin every time. + applications = mkPlugin "applications"; + dictionary = mkPlugin "dictionary"; + kidex = mkPlugin "kidex"; + randr = mkPlugin "randr"; + rink = mkPlugin "rink"; + shell = mkPlugin "shell"; + stdin = mkPlugin "stdin"; + symbols = mkPlugin "symbols"; + translate = mkPlugin "translate"; + websearch = mkPlugin "websearch"; }; # Set up an overlay from packages exposed by this flake overlayAttrs = config.packages; }; - flake = _: rec { - nixosModules.home-manager = homeManagerModules.default; - - homeManagerModules = rec { + flake = {self, ...}: { + homeManagerModules = { anyrun = import ./nix/hm-module.nix inputs.self; - default = anyrun; + default = self.homeManagerModules.anyrun; }; }; }; From deb7801b4db667d44933914a69db77b3cbf32d1c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 3 Jun 2024 19:51:35 +0300 Subject: [PATCH 2/5] nix: follow `nix-systems` linux as the default platforms --- flake.lock | 18 +++++++++++++++++- flake.nix | 7 +++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index c6d5079..b0c3c17 100644 --- a/flake.lock +++ b/flake.lock @@ -39,7 +39,23 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 0bdf39a..6b4bd1e 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; @@ -12,14 +13,12 @@ outputs = inputs @ {flake-parts, ...}: flake-parts.lib.mkFlake {inherit inputs;} { imports = [flake-parts.flakeModules.easyOverlay]; - systems = ["x86_64-linux" "aarch64-linux"]; + systems = import inputs.systems; perSystem = { - config, self', - inputs', + config, pkgs, - system, ... }: let inherit (pkgs) callPackage; From a384914175dc1c5983e1a3587bf0999c76b53a3e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 3 Jun 2024 20:10:08 +0300 Subject: [PATCH 3/5] nix: update flake inputs --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index b0c3c17..046466d 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1696343447, - "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", "type": "github" }, "original": { @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1696193975, - "narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=", + "lastModified": 1717196966, + "narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242", + "rev": "57610d2f8f0937f39dbd72251e9614b1561942d8", "type": "github" }, "original": { From 4064b0b4a75395baf60af9759cf9767afbe66240 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 3 Jun 2024 20:21:03 +0300 Subject: [PATCH 4/5] nix: avoid `with lib;` where applicable --- nix/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index 81cb5fa..08b6a99 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -66,10 +66,10 @@ in --prefix ANYRUN_PLUGINS : $out/lib ''; - meta = with lib; { + meta = { description = "A wayland native, highly customizable runner."; homepage = "https://github.com/Kirottu/anyrun"; - license = with licenses; [gpl3]; + license = with lib.licenses; [gpl3]; maintainers = [ { email = "neo@neoney.dev"; From 8d431d792ab2a53993416c987ec5bb9524b4b7fb Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 3 Jun 2024 20:24:02 +0300 Subject: [PATCH 5/5] CI: use cachix nix installer DetSys one is often inconsistent --- .github/workflows/cachix.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 71edf72..679deb7 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -45,17 +45,16 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main + - uses: cachix/install-nix-action@v26 - uses: DeterminateSystems/magic-nix-cache-action@main - uses: cachix/cachix-action@v12 with: authToken: ${{ secrets.CACHIX_TOKEN }} - extraPullNames: nix-community name: anyrun - name: Set default git branch (to reduce log spam) run: git config --global init.defaultBranch main - name: Build anyrun from the defined matrix - run: nix build .#${{ matrix.package }} --print-build-logs + run: nix build .#${{ matrix.package }} --print-build-logs --extra-substituters "https://anyrun.cachix.org"