From cc465d04d62d5d42c53878480466e3c906c57697 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 29 Feb 2024 15:09:56 +0200 Subject: [PATCH] Nix: refactor flake --- flake.lock | 18 +++++++++++++++++- flake.nix | 37 ++++++++++++++++++++----------------- nix/overlays.nix | 4 +++- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index 705916e..89b4897 100644 --- a/flake.lock +++ b/flake.lock @@ -39,7 +39,23 @@ "root": { "inputs": { "hyprlang": "hyprlang", - "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 fbc5dd5..1174b38 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"; hyprlang = { url = "github:hyprwm/hyprlang"; @@ -10,33 +11,35 @@ }; }; - outputs = inputs: let - inherit (inputs.nixpkgs) lib; - genSystems = lib.genAttrs [ - # Add more systems if they are supported - "x86_64-linux" - "aarch64-linux" - ]; - pkgsFor = genSystems (system: - import inputs.nixpkgs { - overlays = [inputs.self.overlays.default]; - inherit system; + outputs = { + self, + nixpkgs, + systems, + ... + } @ inputs: let + inherit (nixpkgs) lib; + eachSystem = lib.genAttrs (import systems); + + pkgsFor = eachSystem (system: + import nixpkgs { + localSystem.system = system; + overlays = with self.overlays; [default]; }); in { overlays = import ./nix/overlays.nix {inherit inputs lib;}; - packages = genSystems (system: { + packages = eachSystem (system: { + default = self.packages.${system}.hypridle; inherit (pkgsFor.${system}) hypridle; - default = inputs.self.packages.${system}.hypridle; }); homeManagerModules = { - hypridle = import ./nix/hm-module.nix inputs.self; - default = inputs.self.homeManagerModules.hypridle; + default = self.homeManagerModules.hypridle; + hypridle = import ./nix/hm-module.nix self; }; - checks = genSystems (system: inputs.self.packages.${system}); + checks = eachSystem (system: self.packages.${system}); - formatter = genSystems (system: pkgsFor.${system}.alejandra); + formatter = eachSystem (system: pkgsFor.${system}.alejandra); }; } diff --git a/nix/overlays.nix b/nix/overlays.nix index b6544c2..216345e 100644 --- a/nix/overlays.nix +++ b/nix/overlays.nix @@ -8,7 +8,9 @@ (builtins.substring 6 2 longDate) ]); in { - default = lib.composeManyExtensions [ + default = inputs.self.overlays.hypridle; + + hypridle = lib.composeManyExtensions [ inputs.hyprlang.overlays.default (final: prev: { hypridle = prev.callPackage ./default.nix {