Skip to content

Commit

Permalink
Nix: fix the overlay and re-export properly (#26)
Browse files Browse the repository at this point in the history
* flake: made systems overrideable

* flake: do not use legacyPackages

* flake: add overlay named hyprlang

* flake: overlays: do not recurse with rec

* flake: overlays: only use drvs from final fixpoint

* flake: packages: correctly eval own overlay
  • Loading branch information
spikespaz authored Feb 23, 2024
1 parent bbf5c30 commit f446636
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 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.

41 changes: 24 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
{
description = "The official implementation library for the hypr config language";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
};

outputs = {
self,
nixpkgs,
...
systems,
}: let
inherit (nixpkgs) lib;
genSystems = lib.genAttrs [
# Add more systems if they are supported
"x86_64-linux"
"aarch64-linux"
];
pkgsFor = nixpkgs.legacyPackages;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
import nixpkgs {
localSystem.system = system;
overlays = with self.overlays; [hyprlang];
});
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
in {
overlays.default = _: prev: rec {
hyprlang = prev.callPackage ./nix/default.nix {
stdenv = prev.gcc13Stdenv;
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
overlays = {
default = self.overlays.hyprlang;
hyprlang = final: prev: {
hyprlang = final.callPackage ./nix/default.nix {
stdenv = final.gcc13Stdenv;
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
};
hyprlang-with-tests = final.hyprlang.override {doCheck = true;};
};
hyprlang-with-tests = hyprlang.override {doCheck = true;};
};

packages = genSystems (system:
(self.overlays.default null pkgsFor.${system})
// {default = self.packages.${system}.hyprlang;});
packages = eachSystem (system: {
default = self.packages.${system}.hyprlang;
inherit (pkgsFor.${system}) hyprlang hyprlang-with-tests;
});

formatter = genSystems (system: pkgsFor.${system}.alejandra);
formatter = eachSystem (system: pkgsFor.${system}.alejandra);
};
}

0 comments on commit f446636

Please sign in to comment.