diff --git a/flake.lock b/flake.lock index 78b01d1..d05f9cc 100644 --- a/flake.lock +++ b/flake.lock @@ -39,7 +39,23 @@ "root": { "inputs": { "hyprland-protocols": "hyprland-protocols", - "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 015b2c7..a8d16da 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,9 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + # + systems.url = "github:nix-systems/default-linux"; + hyprland-protocols = { url = "github:hyprwm/hyprland-protocols"; inputs.nixpkgs.follows = "nixpkgs"; @@ -13,41 +16,28 @@ outputs = { self, nixpkgs, + systems, ... } @ inputs: let inherit (nixpkgs) lib; - genSystems = lib.genAttrs [ - "aarch64-linux" - "x86_64-linux" - ]; - pkgsFor = genSystems (system: + eachSystem = lib.genAttrs (import systems); + pkgsFor = eachSystem (system: import nixpkgs { - inherit system; + localSystem = system; overlays = [ - self.overlays.default inputs.hyprland-protocols.overlays.default + self.overlays.xdg-desktop-portal-hyprland + self.overlays.hyprland-share-picker ]; }); - mkDate = longDate: (lib.concatStringsSep "-" [ - (builtins.substring 0 4 longDate) - (builtins.substring 4 2 longDate) - (builtins.substring 6 2 longDate) - ]); - version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); in { - overlays.default = final: prev: { - xdg-desktop-portal-hyprland = final.callPackage ./nix/default.nix { - inherit (final) hyprland-protocols hyprland-share-picker; - inherit version; - }; + overlays = import ./nix/overlays.nix {inherit self inputs lib;}; - hyprland-share-picker = final.libsForQt5.callPackage ./nix/hyprland-share-picker.nix {inherit version;}; - }; + packages = eachSystem (system: { + inherit (pkgsFor.${system}) xdg-desktop-portal-hyprland hyprland-share-picker; + default = self.packages.${system}.xdg-desktop-portal-hyprland; + }); - packages = genSystems (system: - (self.overlays.default pkgsFor.${system} pkgsFor.${system}) - // {default = self.packages.${system}.xdg-desktop-portal-hyprland;}); - - formatter = genSystems (system: pkgsFor.${system}.alejandra); + formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra); }; } diff --git a/nix/overlays.nix b/nix/overlays.nix new file mode 100644 index 0000000..1688e5d --- /dev/null +++ b/nix/overlays.nix @@ -0,0 +1,28 @@ +{ + self, + inputs, + lib, +}: let + mkJoinedOverlays = overlays: final: prev: + lib.foldl' (attrs: overlay: attrs // (overlay final prev)) {} overlays; + mkDate = longDate: (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); + version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); +in { + default = mkJoinedOverlays (with self.overlays; [ + xdg-desktop-portal-hyprland + hyprland-share-picker + ]); + xdg-desktop-portal-hyprland = final: prev: { + xdg-desktop-portal-hyprland = final.callPackage ./default.nix { + inherit (final) hyprland-protocols hyprland-share-picker; + inherit version; + }; + }; + hyprland-share-picker = final: prev: { + hyprland-share-picker = final.libsForQt5.callPackage ./hyprland-share-picker.nix {inherit version;}; + }; +}