Skip to content

Commit

Permalink
Nix: Some corrections for overlays (#75)
Browse files Browse the repository at this point in the history
* flake: use legacyPackages for formatter

* nix: separate xdph and share-picker overlays

* flake: make systems overrideable

* flake: inherit packages from overlaid nixpkgs
  • Loading branch information
spikespaz committed Aug 9, 2023
1 parent 42747d2 commit 9257b0c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 26 deletions.
18 changes: 17 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 15 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

# <https://github.com/nix-systems/nix-systems>
systems.url = "github:nix-systems/default-linux";

hyprland-protocols = {
url = "github:hyprwm/hyprland-protocols";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -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;
};

hyprland-share-picker = final.libsForQt5.callPackage ./nix/hyprland-share-picker.nix {inherit version;};
};
overlays = import ./nix/overlays.nix {inherit self inputs lib;};

packages = genSystems (system:
(self.overlays.default pkgsFor.${system} pkgsFor.${system})
// {default = self.packages.${system}.xdg-desktop-portal-hyprland;});
packages = eachSystem (system: {
inherit (pkgsFor.${system}) xdg-desktop-portal-hyprland hyprland-share-picker;
default = self.packages.${system}.xdg-desktop-portal-hyprland;
});

formatter = genSystems (system: pkgsFor.${system}.alejandra);
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
};
}
28 changes: 28 additions & 0 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
@@ -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;};
};
}

0 comments on commit 9257b0c

Please sign in to comment.